24#include <wx/filename.h>
32#if defined( _MSC_VER ) || !defined( USE_MSYS2_FALLBACK )
35 HANDLE hFile = INVALID_HANDLE_VALUE;
36 hFile = CreateFileW( aPath.wc_str(),
41 FILE_FLAG_SEQUENTIAL_SCAN,
44 if (hFile == INVALID_HANDLE_VALUE)
49 int fd = _open_osfhandle(
reinterpret_cast<intptr_t
>( hFile ), 0 );
58 FILE* fp = _fdopen( fd, aMode.c_str() );
69 return wxFopen( aPath, aMode );
79 if( GetFileSecurity( aSrc.wc_str(),
80 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
88 BYTE* pSD =
new BYTE[dwSize];
90 PSECURITY_DESCRIPTOR pSD =
static_cast<PSECURITY_DESCRIPTOR
>(
new BYTE[dwSize] );
96 if( !GetFileSecurity( aSrc.wc_str(),
97 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
98 | DACL_SECURITY_INFORMATION, pSD, dwSize, &dwSize ) )
105 if( !SetFileSecurity( aDest.wc_str(),
106 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
107 | DACL_SECURITY_INFORMATION, pSD ) )
122 if( ( GetFileAttributesW( aFileName.fn_str() ) & FILE_ATTRIBUTE_HIDDEN ) )
135 if( aFilename.GetVolume().Length() == 1 )
137 aFilename.SetVolume(
"\\\\?\\" + aFilename.GetVolume() +
":" );
138 else if( aFilename.GetVolume().Length() > 1
139 && aFilename.GetVolume().StartsWith( wxT(
"\\\\" ) )
140 && !aFilename.GetVolume().StartsWith( wxT(
"\\\\?" ) ) )
145 aFilename.SetVolume(
"\\\\?\\UNC" + aFilename.GetVolume().Mid( 1 ) );
146 else if( aFilename.GetVolume().StartsWith( wxT(
"\\\\?" ) )
147 && aFilename.GetDirs().size() >= 2
148 && aFilename.GetDirs()[0] ==
"UNC" )
154 aFilename.SetVolume(
"\\\\?\\UNC\\" + aFilename.GetDirs()[1] );
155 aFilename.RemoveDir( 0 );
156 aFilename.RemoveDir( 0 );