X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwin32.c;h=483518c99bab9c4c0609d9d39ae62f5c5fa5099f;hb=8f520d21297a3ae557d82b586ad369662714d829;hp=e2dc6a1b4396c2152413700b855232235d379fde;hpb=8c26ca707e56d9848e52076ad3f7c26ea7fa338d;p=wimlib diff --git a/src/win32.c b/src/win32.c index e2dc6a1b..483518c9 100644 --- a/src/win32.c +++ b/src/win32.c @@ -1068,10 +1068,12 @@ static int win32_set_security_data(const struct wim_inode *inode, return 0; } -int win32_apply_dentry(const char *output_path, - size_t output_path_len, - const struct wim_dentry *dentry, - struct apply_args *args) +/* Extract a file, directory, reparse point, or hard link to an + * already-extracted file using the Win32 API */ +int win32_do_apply_dentry(const char *output_path, + size_t output_path_len, + struct wim_dentry *dentry, + struct apply_args *args) { char *utf16_path; size_t utf16_path_len; @@ -1133,10 +1135,11 @@ out: return ret; } -int win32_apply_dentry_timestamps(const char *output_path, - size_t output_path_len, - const struct wim_dentry *dentry, - const struct apply_args *args) +/* Set timestamps on an extracted file using the Win32 API */ +int win32_do_apply_dentry_timestamps(const char *output_path, + size_t output_path_len, + const struct wim_dentry *dentry, + const struct apply_args *args) { /* Win32 */ char *utf16_path; @@ -1208,9 +1211,37 @@ int fsync(int fd) return 0; } +/* Use the Win32 API to get the number of processors */ unsigned win32_get_number_of_processors() { SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); return sysinfo.dwNumberOfProcessors; } + +/* Replacement for POSIX-2008 realpath(). Warning: partial functionality only + * (resolved_path must be NULL). Also I highly doubt that GetFullPathName + * really does the right thing under all circumstances. */ +char *realpath(const char *path, char *resolved_path) +{ + DWORD ret; + wimlib_assert(resolved_path == NULL); + + ret = GetFullPathNameA(path, 0, NULL, NULL); + if (!ret) + goto fail_win32; + + resolved_path = MALLOC(ret + 1); + if (!resolved_path) + goto fail; + ret = GetFullPathNameA(path, ret, resolved_path, NULL); + if (!ret) { + free(resolved_path); + goto fail_win32; + } + return resolved_path; +fail_win32: + win32_error(GetLastError()); +fail: + return NULL; +}