From c11aa5c9aa0c3bf827811141eef4989d03a5c99e Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Fri, 28 Jun 2024 20:03:00 +0200 Subject: [PATCH] removed more windows code --- lib/pclsync/pdownload.c | 41 -- lib/pclsync/pexternalstatus.c | 4 - lib/pclsync/pfolder.c | 49 -- lib/pclsync/pfolder.h | 3 - lib/pclsync/pfs.c | 42 -- lib/pclsync/pfs.h | 2 +- lib/pclsync/pfsstatic.c | 828 ---------------------------------- lib/pclsync/pfsxattr.c | 7 +- lib/pclsync/plibs.c | 5 - lib/pclsync/plocalnotify.c | 133 ------ 10 files changed, 2 insertions(+), 1112 deletions(-) diff --git a/lib/pclsync/pdownload.c b/lib/pclsync/pdownload.c index d62d88b..f907226 100644 --- a/lib/pclsync/pdownload.c +++ b/lib/pclsync/pdownload.c @@ -984,39 +984,6 @@ static void handle_async_error(download_task_t *dt, psync_async_result_t *res){ psync_timer_register(free_task_timer, 1, dt); } -#if defined(P_OS_WINDOWS) - -typedef struct { - psync_async_result_t res; - download_task_t *dt; -} async_res_dt_t; - -static void rename_create_thread(void *ptr){ - async_res_dt_t *ard; - ard=(async_res_dt_t *)ptr; - if (rename_and_create_local(ard->dt, ard->res.file.sha1hex, ard->res.file.size, ard->res.file.hash)){ - set_task_inprogress(ard->dt->taskid, 0); - free_download_task(ard->dt); - psync_free(ard); - psync_send_status_update(); - psync_wake_download(); - } - else{ - delete_task(ard->dt->taskid); - psync_path_status_sync_folder_task_completed(ard->dt->dwllist.syncid, ard->dt->localfolderid); - free_download_task(ard->dt); - psync_free(ard); - psync_status_recalc_to_download_async(); - } -} - -static void rename_create_timer(psync_timer_t timer, void *ptr){ - psync_timer_stop(timer); - psync_run_thread1("small file dwl db ins", rename_create_thread, ptr); -} - -#endif - static void finish_async_download(void *ptr, psync_async_result_t *res){ download_task_t *dt=(download_task_t *)ptr; if (res->error) @@ -1027,13 +994,6 @@ static void finish_async_download(void *ptr, psync_async_result_t *res){ psync_file_delete(dt->tmpname); return; } -#if defined(P_OS_WINDOWS) - async_res_dt_t *ard; - ard=psync_new(async_res_dt_t); - memcpy(&ard->res, res, sizeof(psync_async_result_t)); - ard->dt=dt; - psync_timer_register(rename_create_timer, 2, ard); -#else if (rename_and_create_local(dt, res->file.sha1hex, res->file.size, res->file.hash)) psync_timer_register(free_task_timer, 1, dt); else{ @@ -1042,7 +1002,6 @@ static void finish_async_download(void *ptr, psync_async_result_t *res){ free_download_task(dt); psync_status_recalc_to_download_async(); } -#endif } } diff --git a/lib/pclsync/pexternalstatus.c b/lib/pclsync/pexternalstatus.c index 0643eca..e01256a 100644 --- a/lib/pclsync/pexternalstatus.c +++ b/lib/pclsync/pexternalstatus.c @@ -41,11 +41,7 @@ #define MAX_RECURS_DEPTH 31 -#ifdef P_OS_WINDOWS -#define SLASHCHAR '\\' -#else #define SLASHCHAR '/' -#endif static int sync_offline() { if (psync_status_is_offline() || diff --git a/lib/pclsync/pfolder.c b/lib/pclsync/pfolder.c index 1458503..6cc251b 100644 --- a/lib/pclsync/pfolder.c +++ b/lib/pclsync/pfolder.c @@ -40,9 +40,6 @@ #include "pcloudcrypto.h" #include "pdiff.h" #include "pfsfolder.h" -#ifdef P_OS_WINDOWS -#include "Shlobj.h" -#endif #define INITIAL_NAME_BUFF 2000 #define INITIAL_ENTRY_CNT 128 @@ -985,49 +982,3 @@ psync_folder_list_t *psync_list_get_list(char* syncTypes){ return ret; } -#ifdef P_OS_WINDOWS -void psync_fsfolder_refresh_path(char *folderpath){ - LPITEMIDLIST pidl; - LPSHELLFOLDER pdesktopfolder; - OLECHAR olepath[MAX_PATH]; - ULONG cheaten; - ULONG attributes; - HRESULT hr; - DWORD lasterror; - debug(D_NOTICE, "Trying to refresh the Windows Explorer windows with open path: %s", folderpath); - if (likely(SUCCEEDED(SHGetDesktopFolder(&pdesktopfolder)))){ - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, folderpath, -1, olepath, MAX_PATH); - SetLastError(0); - hr=pdesktopfolder->lpVtbl->ParseDisplayName(pdesktopfolder, NULL, NULL, olepath, &cheaten, &pidl, &attributes); - lasterror=GetLastError(); - if (unlikely(FAILED(hr))){ - debug(D_NOTICE, "Failed to get directory ITEMIDLIST for path: %s, LastError: %d", folderpath, lasterror); - } - else{ - // pidl now contains a pointer to an ITEMIDLIST. - // This ITEMIDLIST needs to be freed using the IMalloc allocator - // returned from SHGetMalloc() or by calling the CoTaskMemFree() function - SetLastError(0); - SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST|SHCNF_FLUSHNOWAIT, pidl, NULL); // Refresh all Windows Explorer windows with open folderpath - if ((lasterror=GetLastError())) - debug(D_NOTICE, "Failed to send SHCNE_UPDATEDIR event, last error: %d", lasterror); - else - debug(D_NOTICE, "Successufly sent SHCNE_UPDATEDIR event for %s", folderpath); - CoTaskMemFree(pidl); - } - pdesktopfolder->lpVtbl->Release(pdesktopfolder); - } -} - -void psync_refresh_explorer_crypto_folder(){ - const char* cfname="\\Crypto Folder\\"; - char *cfolderpath=NULL; - cfolderpath=psync_fs_getmountpoint(); - if (cfolderpath){ - cfolderpath=(char*)realloc(cfolderpath, strlen(cfolderpath)+strlen(cfname)+1); - strcat(cfolderpath, cfname); - psync_fsfolder_refresh_path(cfolderpath); - psync_free(cfolderpath); - } -} -#endif diff --git a/lib/pclsync/pfolder.h b/lib/pclsync/pfolder.h index 9c713ce..5475424 100644 --- a/lib/pclsync/pfolder.h +++ b/lib/pclsync/pfolder.h @@ -64,7 +64,4 @@ psync_folder_list_t* psync_list_get_list(char* syncTypes); psync_folderid_t psync_wait_folder_in_local_db(psync_folderid_t folderid); -#ifdef P_OS_WINDOWS -void psync_refresh_explorer_crypto_folder(); -#endif #endif diff --git a/lib/pclsync/pfs.c b/lib/pclsync/pfs.c index 0c4ac7d..a29930e 100644 --- a/lib/pclsync/pfs.c +++ b/lib/pclsync/pfs.c @@ -103,9 +103,6 @@ typedef off_t fuse_off_t; #if defined(P_OS_LINUX) #define PSYNC_FS_ERR_CRYPTO_EXPIRED EROFS #define PSYNC_FS_ERR_MOVE_ACROSS_CRYPTO EXDEV -#elif defined(P_OS_WINDOWS) -#define PSYNC_FS_ERR_CRYPTO_EXPIRED EACCES -#define PSYNC_FS_ERR_MOVE_ACROSS_CRYPTO EACCES #else #define PSYNC_FS_ERR_CRYPTO_EXPIRED EIO #define PSYNC_FS_ERR_MOVE_ACROSS_CRYPTO EXDEV @@ -3158,43 +3155,6 @@ void psync_fs_refresh_folder(psync_folderid_t folderid){ psync_free(fpath); } -#if defined(P_OS_WINDOWS) - -static int is_mountable(char where){ - DWORD drives = GetLogicalDrives(); - where = tolower(where) - 'a'; - return !(drives & (1< -#else -// No xattr in win. // Value get from standard xattr.h enum { @@ -59,7 +54,7 @@ enum XATTR_REPLACE = 2 /* set value, fail if attr does not exist. */ #define XATTR_REPLACE XATTR_REPLACE }; -#endif + #ifndef ENODATA #define ENODATA 61 diff --git a/lib/pclsync/plibs.c b/lib/pclsync/plibs.c index 424ec07..dae1422 100644 --- a/lib/pclsync/plibs.c +++ b/lib/pclsync/plibs.c @@ -2470,11 +2470,6 @@ int psync_debug(const char *file, const char *function, int unsigned line, int u psync_uint_t i; unsigned int u; pthread_t threadid; -#if defined(P_OS_WINDOWS) - errname=strrchr(file, '\\'); - if (errname) - file=errname+1; -#endif errname="BAD_ERROR_CODE"; for (i=0; i=WAIT_OBJECT_0 && ret