2017-05-23 11:39:12 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Setup Library
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* PURPOSE: File support functions.
|
2018-01-05 00:56:23 +00:00
|
|
|
* COPYRIGHT: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
|
|
|
* Copyright 2017-2018 Hermes Belusca-Maito
|
2017-05-23 11:39:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-01-05 00:56:23 +00:00
|
|
|
NTSTATUS
|
|
|
|
SetupCreateDirectory(
|
2024-08-07 20:31:01 +00:00
|
|
|
_In_ PCWSTR PathName);
|
2018-01-05 00:56:23 +00:00
|
|
|
|
2017-06-30 22:28:06 +00:00
|
|
|
NTSTATUS
|
|
|
|
SetupDeleteFile(
|
|
|
|
IN PCWSTR FileName,
|
|
|
|
IN BOOLEAN ForceDelete); // ForceDelete can be used to delete read-only files
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
SetupCopyFile(
|
|
|
|
IN PCWSTR SourceFileName,
|
|
|
|
IN PCWSTR DestinationFileName,
|
|
|
|
IN BOOLEAN FailIfExists);
|
2017-05-23 11:39:12 +00:00
|
|
|
|
2017-06-30 22:28:06 +00:00
|
|
|
#ifndef _WINBASE_
|
|
|
|
|
|
|
|
#define MOVEFILE_REPLACE_EXISTING 1
|
|
|
|
#define MOVEFILE_COPY_ALLOWED 2
|
|
|
|
#define MOVEFILE_WRITE_THROUGH 8
|
2017-05-23 11:39:12 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-06-30 22:28:06 +00:00
|
|
|
NTSTATUS
|
|
|
|
SetupMoveFile(
|
|
|
|
IN PCWSTR ExistingFileName,
|
|
|
|
IN PCWSTR NewFileName,
|
|
|
|
IN ULONG Flags);
|
|
|
|
|
2017-05-23 22:30:54 +00:00
|
|
|
NTSTATUS
|
|
|
|
ConcatPathsV(
|
|
|
|
IN OUT PWSTR PathBuffer,
|
|
|
|
IN SIZE_T cchPathSize,
|
|
|
|
IN ULONG NumberOfPathComponents,
|
|
|
|
IN va_list PathComponentsList);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
CombinePathsV(
|
|
|
|
OUT PWSTR PathBuffer,
|
|
|
|
IN SIZE_T cchPathSize,
|
|
|
|
IN ULONG NumberOfPathComponents,
|
|
|
|
IN va_list PathComponentsList);
|
|
|
|
|
2017-05-23 11:39:12 +00:00
|
|
|
NTSTATUS
|
|
|
|
ConcatPaths(
|
2017-05-23 22:30:54 +00:00
|
|
|
IN OUT PWSTR PathBuffer,
|
|
|
|
IN SIZE_T cchPathSize,
|
|
|
|
IN ULONG NumberOfPathComponents,
|
|
|
|
IN /* PCWSTR */ ...);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
CombinePaths(
|
|
|
|
OUT PWSTR PathBuffer,
|
2017-05-23 11:39:12 +00:00
|
|
|
IN SIZE_T cchPathSize,
|
2017-05-23 22:30:54 +00:00
|
|
|
IN ULONG NumberOfPathComponents,
|
|
|
|
IN /* PCWSTR */ ...);
|
2017-05-23 11:39:12 +00:00
|
|
|
|
2024-08-07 20:31:01 +00:00
|
|
|
BOOLEAN
|
|
|
|
DoesPathExist_UStr(
|
|
|
|
_In_opt_ HANDLE RootDirectory,
|
|
|
|
_In_ PCUNICODE_STRING PathName,
|
|
|
|
_In_ BOOLEAN IsDirectory);
|
|
|
|
|
2017-05-23 11:39:12 +00:00
|
|
|
BOOLEAN
|
2017-08-21 19:41:40 +00:00
|
|
|
DoesPathExist(
|
2024-08-07 20:31:01 +00:00
|
|
|
_In_opt_ HANDLE RootDirectory,
|
|
|
|
_In_ PCWSTR PathName,
|
|
|
|
_In_ BOOLEAN IsDirectory);
|
2017-05-23 11:39:12 +00:00
|
|
|
|
2017-08-21 19:41:40 +00:00
|
|
|
#define DoesDirExist(RootDirectory, DirName) \
|
|
|
|
DoesPathExist((RootDirectory), (DirName), TRUE)
|
2017-08-21 19:14:33 +00:00
|
|
|
|
|
|
|
#define DoesFileExist(RootDirectory, FileName) \
|
2017-08-21 19:41:40 +00:00
|
|
|
DoesPathExist((RootDirectory), (FileName), FALSE)
|
2017-05-24 16:37:49 +00:00
|
|
|
|
|
|
|
// FIXME: DEPRECATED! HACKish function that needs to be deprecated!
|
|
|
|
BOOLEAN
|
|
|
|
DoesFileExist_2(
|
2017-05-23 11:39:12 +00:00
|
|
|
IN PCWSTR PathName OPTIONAL,
|
|
|
|
IN PCWSTR FileName);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NtPathToDiskPartComponents(
|
|
|
|
IN PCWSTR NtPath,
|
|
|
|
OUT PULONG pDiskNumber,
|
|
|
|
OUT PULONG pPartNumber,
|
|
|
|
OUT PCWSTR* PathComponent OPTIONAL);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
OpenAndMapFile(
|
2024-05-04 10:35:24 +00:00
|
|
|
_In_opt_ HANDLE RootDirectory,
|
|
|
|
_In_ PCWSTR PathNameToFile,
|
|
|
|
_Out_opt_ PHANDLE FileHandle,
|
|
|
|
_Out_opt_ PULONG FileSize,
|
|
|
|
_Out_ PHANDLE SectionHandle,
|
|
|
|
_Out_ PVOID* BaseAddress,
|
|
|
|
_In_ BOOLEAN ReadWriteAccess);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
MapFile(
|
|
|
|
_In_ HANDLE FileHandle,
|
|
|
|
_Out_ PHANDLE SectionHandle,
|
|
|
|
_Out_ PVOID* BaseAddress,
|
|
|
|
_In_ BOOLEAN ReadWriteAccess);
|
2017-05-23 11:39:12 +00:00
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
UnMapFile(
|
2024-05-04 10:35:24 +00:00
|
|
|
_In_ HANDLE SectionHandle,
|
|
|
|
_In_ PVOID BaseAddress);
|
2017-05-23 11:39:12 +00:00
|
|
|
|
2017-08-23 12:20:15 +00:00
|
|
|
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress) \
|
|
|
|
do { \
|
|
|
|
UnMapFile((SectionHandle), (BaseAddress)); \
|
|
|
|
NtClose(FileHandle); \
|
|
|
|
} while (0)
|
|
|
|
|
2017-05-23 11:39:12 +00:00
|
|
|
/* EOF */
|