-
Notifications
You must be signed in to change notification settings - Fork 1
/
FileRoutines.h
102 lines (75 loc) · 3.57 KB
/
FileRoutines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the LICENSE file distributed with
* this work for additional information regarding copyright ownership.
*
* Also, if exists, check the Licenses directory for information about
* third-party modules.
*
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _MXLIBHLP_FILE_ROUTINES_H
#define _MXLIBHLP_FILE_ROUTINES_H
#include <Defines.h>
#include <Strings\Strings.h>
#include <ArrayList.h>
//-----------------------------------------------------------
namespace MX {
namespace FileRoutines {
enum class eDelayedDelete
{
DontTryDeleteOnReboot,
DeleteOnRebootOnFailure,
WaitUntilReboot
} ;
}; //namespace FileRoutines
}; //namespace MX
//-----------------------------------------------------------
namespace MX {
namespace FileRoutines {
HRESULT GetAppFileName(_Out_ CStringW &cStrDestW);
HRESULT GetAppFolderPath(_Out_ CStringW &cStrDestW);
HRESULT GetProcessFileName(_In_ DWORD dwPid, _Out_ CStringW &cStrDestW);
HRESULT GetProcessFileName(_In_ HANDLE hProc, _Out_ CStringW &cStrDestW);
HRESULT GetCommonAppDataFolderPath(_Out_ CStringW &cStrDestW);
HRESULT GetProgramFilesFolderPath(_Out_ CStringW &cStrDestW);
#if defined(_M_X64)
HRESULT GetProgramFilesX86FolderPath(_Out_ CStringW &cStrDestW);
#endif //_M_X64
HRESULT GetWindowsPath(_Out_ CStringW &cStrDestW);
HRESULT GetWindowsSystemPath(_Out_ CStringW &cStrDestW);
#if defined(_M_X64)
HRESULT GetWindowsSysWow64Path(_Out_ CStringW &cStrDestW);
#endif //_M_X64
HRESULT _GetTempPath(_Out_ CStringW &cStrDestW);
HRESULT CreateDirectoryRecursive(_In_ LPCWSTR szFolderNameW);
HRESULT RemoveDirectoryRecursive(_In_ LPCWSTR szFolderNameW,
_In_opt_ FileRoutines::eDelayedDelete nDD = FileRoutines::eDelayedDelete::DontTryDeleteOnReboot);
HRESULT _DeleteFile(_In_ LPCWSTR szFileNameW,
_In_opt_ FileRoutines::eDelayedDelete nDD = FileRoutines::eDelayedDelete::DontTryDeleteOnReboot);
HRESULT DeleteDirectoryFiles(_In_ LPCWSTR szFolderNameW,
_In_opt_ FileRoutines::eDelayedDelete nDD = FileRoutines::eDelayedDelete::DontTryDeleteOnReboot);
VOID NormalizePath(_Inout_ CStringW &cStrPathW);
HRESULT ConvertToLongPath(_Inout_ CStringW &cStrPathW);
HRESULT ConvertToNative(_Inout_ CStringW &cStrPathW);
HRESULT ConvertToWin32(_Inout_ CStringW &cStrPathW);
HRESULT DeviceName2DosName(_Inout_ CStringW &cStrPathW);
HRESULT ResolveSymbolicLink(_Inout_ CStringW &cStrPathW);
//Returned filename is in NT format
HRESULT GetFileNameFromHandle(_In_ HANDLE hFile, _Out_ CStringW &cStrFileNameW);
HRESULT OpenFileWithEscalatingSharing(_In_z_ LPCWSTR szFileNameW, _Out_ HANDLE *lphFile);
HRESULT CreateFileWithOptions(_In_z_ LPCWSTR szFileNameW, _Out_ HANDLE *lphFile, _In_opt_ BOOL bCreateDirectory = TRUE,
_In_opt_ BOOL bReplaceExisting = TRUE, _In_opt_ DWORD dwSharedMode = 0);
}; //namespace FileRoutines
}; //namespace MX
//-----------------------------------------------------------
#endif //_MXLIBHLP_FILE_ROUTINES_H