xref: /reactos/base/setup/lib/utils/filesup.h (revision 1734f297)
1 /*
2  * PROJECT:     ReactOS Setup Library
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     File support functions.
5  * COPYRIGHT:   Casper S. Hornstrup (chorns@users.sourceforge.net)
6  *              Copyright 2017-2018 Hermes Belusca-Maito
7  */
8 
9 #pragma once
10 
11 NTSTATUS
12 SetupCreateDirectory(
13     IN PCWSTR DirectoryName);
14 
15 NTSTATUS
16 SetupDeleteFile(
17     IN PCWSTR FileName,
18     IN BOOLEAN ForceDelete); // ForceDelete can be used to delete read-only files
19 
20 NTSTATUS
21 SetupCopyFile(
22     IN PCWSTR SourceFileName,
23     IN PCWSTR DestinationFileName,
24     IN BOOLEAN FailIfExists);
25 
26 #ifndef _WINBASE_
27 
28 #define MOVEFILE_REPLACE_EXISTING   1
29 #define MOVEFILE_COPY_ALLOWED       2
30 #define MOVEFILE_WRITE_THROUGH      8
31 
32 #endif
33 
34 NTSTATUS
35 SetupMoveFile(
36     IN PCWSTR ExistingFileName,
37     IN PCWSTR NewFileName,
38     IN ULONG Flags);
39 
40 NTSTATUS
41 ConcatPathsV(
42     IN OUT PWSTR PathBuffer,
43     IN SIZE_T cchPathSize,
44     IN ULONG NumberOfPathComponents,
45     IN va_list PathComponentsList);
46 
47 NTSTATUS
48 CombinePathsV(
49     OUT PWSTR PathBuffer,
50     IN SIZE_T cchPathSize,
51     IN ULONG NumberOfPathComponents,
52     IN va_list PathComponentsList);
53 
54 NTSTATUS
55 ConcatPaths(
56     IN OUT PWSTR PathBuffer,
57     IN SIZE_T cchPathSize,
58     IN ULONG NumberOfPathComponents,
59     IN /* PCWSTR */ ...);
60 
61 NTSTATUS
62 CombinePaths(
63     OUT PWSTR PathBuffer,
64     IN SIZE_T cchPathSize,
65     IN ULONG NumberOfPathComponents,
66     IN /* PCWSTR */ ...);
67 
68 BOOLEAN
69 DoesPathExist(
70     IN HANDLE RootDirectory OPTIONAL,
71     IN PCWSTR PathName,
72     IN BOOLEAN IsDirectory);
73 
74 #define DoesDirExist(RootDirectory, DirName)    \
75     DoesPathExist((RootDirectory), (DirName), TRUE)
76 
77 #define DoesFileExist(RootDirectory, FileName)  \
78     DoesPathExist((RootDirectory), (FileName), FALSE)
79 
80 // FIXME: DEPRECATED! HACKish function that needs to be deprecated!
81 BOOLEAN
82 DoesFileExist_2(
83     IN PCWSTR PathName OPTIONAL,
84     IN PCWSTR FileName);
85 
86 BOOLEAN
87 NtPathToDiskPartComponents(
88     IN PCWSTR NtPath,
89     OUT PULONG pDiskNumber,
90     OUT PULONG pPartNumber,
91     OUT PCWSTR* PathComponent OPTIONAL);
92 
93 NTSTATUS
94 OpenAndMapFile(
95     IN  HANDLE RootDirectory OPTIONAL,
96     IN  PCWSTR PathNameToFile,
97     OUT PHANDLE FileHandle,         // IN OUT PHANDLE OPTIONAL
98     OUT PHANDLE SectionHandle,
99     OUT PVOID* BaseAddress,
100     OUT PULONG FileSize OPTIONAL,
101     IN  BOOLEAN ReadWriteAccess);
102 
103 BOOLEAN
104 UnMapFile(
105     IN HANDLE SectionHandle,
106     IN PVOID BaseAddress);
107 
108 #define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress)   \
109 do {    \
110     UnMapFile((SectionHandle), (BaseAddress));  \
111     NtClose(FileHandle);                        \
112 } while (0)
113 
114 /* EOF */
115