From: Eric Biggers Date: Sun, 17 Mar 2013 21:35:23 +0000 (-0500) Subject: Move realpath() to win32.c X-Git-Tag: v1.3.0~18 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=406df77b8a9c2bb3318cf7737702eac27041e41e Move realpath() to win32.c --- diff --git a/src/wim.c b/src/wim.c index 1ffc3fef..70e8e73b 100644 --- a/src/wim.c +++ b/src/wim.c @@ -25,58 +25,28 @@ #include "config.h" -#ifdef __WIN32__ -# include -# ifdef ERROR -# undef ERROR -# endif -#endif - +#include +#include #include -#include #include -#include - -#include "dentry.h" +#include #include -#include #ifdef WITH_NTFS_3G -#include -#include +# include +# include +#endif + +#ifdef __WIN32__ +# include "win32.h" #endif -#include "wimlib_internal.h" #include "buffer_io.h" +#include "dentry.h" #include "lookup_table.h" +#include "wimlib_internal.h" #include "xml.h" -#ifdef __WIN32__ -static 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; -} -#endif - static int image_print_metadata(WIMStruct *w) { DEBUG("Printing metadata for image %d", w->current_image); diff --git a/src/win32.c b/src/win32.c index e2dc6a1b..775e782e 100644 --- a/src/win32.c +++ b/src/win32.c @@ -1214,3 +1214,27 @@ unsigned win32_get_number_of_processors() GetSystemInfo(&sysinfo); return sysinfo.dwNumberOfProcessors; } + +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; +} diff --git a/src/win32.h b/src/win32.h index e702d69a..084eb6b2 100644 --- a/src/win32.h +++ b/src/win32.h @@ -50,4 +50,6 @@ extern int fsync(int fd); extern unsigned win32_get_number_of_processors(); +extern char *realpath(const char *path, char *resolved_path); + #endif /* _WIMLIB_WIN32_H */