+set_short_name(HANDLE h, const struct wim_dentry *dentry,
+ struct win32_apply_ctx *ctx)
+{
+ size_t bufsize = offsetof(FILE_NAME_INFORMATION, FileName) +
+ dentry->short_name_nbytes;
+ u8 buf[bufsize] _aligned_attribute(8);
+ FILE_NAME_INFORMATION *info = (FILE_NAME_INFORMATION *)buf;
+ NTSTATUS status;
+
+ info->FileNameLength = dentry->short_name_nbytes;
+ memcpy(info->FileName, dentry->short_name, dentry->short_name_nbytes);
+
+ status = (*func_NtSetInformationFile)(h, &ctx->iosb, info, bufsize,
+ FileShortNameInformation);
+ if (NT_SUCCESS(status))
+ return 0;
+
+ /* By default, failure to set short names is not an error (since short
+ * names aren't too important anymore...). */
+ if (!(ctx->common.extract_flags & WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES))
+ return 0;
+
+ if (status == STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME) {
+ if (dentry->short_name_nbytes == 0)
+ return 0;
+ ERROR("Can't extract short name when short "
+ "names are not enabled on the volume!");
+ } else {
+ ERROR("Can't set short name on \"%ls\" (status=0x%08"PRIx32")",
+ current_path(ctx), (u32)status);
+ }
+ return WIMLIB_ERR_SET_SHORT_NAME;
+}
+
+/*
+ * A wrapper around NtCreateFile() to make it slightly more usable...
+ * This uses the path currently constructed in ctx->pathbuf.
+ *
+ * Also, we always specify FILE_OPEN_FOR_BACKUP_INTENT and
+ * FILE_OPEN_REPARSE_POINT.
+ */
+static NTSTATUS
+do_create_file(PHANDLE FileHandle,
+ ACCESS_MASK DesiredAccess,
+ PLARGE_INTEGER AllocationSize,
+ ULONG FileAttributes,
+ ULONG CreateDisposition,
+ ULONG CreateOptions,
+ struct win32_apply_ctx *ctx)
+{
+ return (*func_NtCreateFile)(FileHandle,
+ DesiredAccess,
+ &ctx->attr,
+ &ctx->iosb,
+ AllocationSize,
+ FileAttributes,
+ FILE_SHARE_VALID_FLAGS,
+ CreateDisposition,
+ CreateOptions |
+ FILE_OPEN_FOR_BACKUP_INTENT |
+ FILE_OPEN_REPARSE_POINT,
+ NULL,
+ 0);
+}
+
+/* Like do_create_file(), but builds the extraction path of the @dentry first.
+ */
+static NTSTATUS
+create_file(PHANDLE FileHandle,
+ ACCESS_MASK DesiredAccess,
+ PLARGE_INTEGER AllocationSize,
+ ULONG FileAttributes,
+ ULONG CreateDisposition,
+ ULONG CreateOptions,
+ const struct wim_dentry *dentry,
+ struct win32_apply_ctx *ctx)
+{
+ build_extraction_path(dentry, ctx);
+ return do_create_file(FileHandle,
+ DesiredAccess,
+ AllocationSize,
+ FileAttributes,
+ CreateDisposition,
+ CreateOptions,
+ ctx);
+}
+
+/* Create empty named data streams.
+ *
+ * Since these won't have 'struct wim_lookup_table_entry's, they won't show up
+ * in the call to extract_stream_list(). Hence the need for the special case.
+ */
+static int
+create_any_empty_ads(const struct wim_dentry *dentry,
+ struct win32_apply_ctx *ctx)