]> wimlib.net Git - wimlib/blobdiff - src/extract_image.c
Windows native build
[wimlib] / src / extract_image.c
index 6fb944272d65634e7d1c8e2c9eda6132901300d0..86063819ab26c2e363fbbb8257544afc9efa4efc 100644 (file)
 #include <alloca.h>
 #endif
 
+#if defined(__WIN32__)
+#      define swprintf _snwprintf
+#      define mkdir(path, mode) (!CreateDirectoryA(path, NULL))
+#endif
+
 #if defined(__CYGWIN__) || defined(__WIN32__)
 
 static int win32_set_reparse_data(HANDLE h,
@@ -775,7 +780,6 @@ static int apply_dentry_timestamps_normal(struct wim_dentry *dentry, void *arg)
        size_t utf16_path_len;
        DWORD err;
        HANDLE h;
-       BOOL bret1, bret2;
 
        ret = utf8_to_utf16(output_path, len, &utf16_path, &utf16_path_len);
        if (ret)
@@ -1319,6 +1323,11 @@ WIMLIBAPI int wimlib_extract_image(WIMStruct *w,
                w->lookup_table = joined_tab;
        }
 
+#if defined(__CYGWIN__) || defined(__WIN32__)
+       win32_acquire_privilege(SE_RESTORE_NAME);
+       win32_acquire_privilege(SE_SECURITY_NAME);
+       win32_acquire_privilege(SE_TAKE_OWNERSHIP_NAME);
+#endif
        if (image == WIMLIB_ALL_IMAGES) {
                extract_flags |= WIMLIB_EXTRACT_FLAG_MULTI_IMAGE;
                ret = extract_all_images(w, target, extract_flags,
@@ -1328,6 +1337,11 @@ WIMLIBAPI int wimlib_extract_image(WIMStruct *w,
                ret = extract_single_image(w, image, target, extract_flags,
                                           progress_func);
        }
+#if defined(__CYGWIN__) || defined(__WIN32__)
+       win32_release_privilege(SE_RESTORE_NAME);
+       win32_release_privilege(SE_SECURITY_NAME);
+       win32_release_privilege(SE_TAKE_OWNERSHIP_NAME);
+#endif
 
        if (extract_flags & (WIMLIB_EXTRACT_FLAG_SYMLINK |
                             WIMLIB_EXTRACT_FLAG_HARDLINK))