+
+#ifdef __WIN32__
+ /* Work around defective behavior in Windows where paths longer than 260
+ * characters are not supported by default; instead they need to be
+ * turned into absolute paths and prefixed with "\\?\". */
+ args.target_lowlevel_path = MALLOC(32768 * sizeof(wchar_t));
+ if (!args.target_lowlevel_path)
+ {
+ ret = WIMLIB_ERR_NOMEM;
+ goto out;
+ }
+ args.target_lowlevel_path[0] = L'\\';
+ args.target_lowlevel_path[1] = L'\\';
+ args.target_lowlevel_path[2] = L'?';
+ args.target_lowlevel_path[3] = L'\\';
+ args.target_lowlevel_path_nchars =
+ GetFullPathName(args.target, 32768 - 4,
+ &args.target_lowlevel_path[4], NULL);
+
+ if (args.target_lowlevel_path_nchars == 0 ||
+ args.target_lowlevel_path_nchars >= 32768 - 4)
+ {
+ WARNING("Can't get full path name for \"%ls\"", args.target);
+ FREE(args.target_lowlevel_path);
+ args.target_lowlevel_path = NULL;
+ } else {
+ args.target_lowlevel_path_nchars += 4;
+ }
+#endif