Fix MSW and OSX kiplatform io libs
Takes fixes from master branch. Includes ff072feeb4
This commit is contained in:
parent
228927b4e9
commit
d3aa304556
|
@ -73,20 +73,27 @@ FILE* KIPLATFORM::IO::SeqFOpen( const wxString& aPath, const wxString& aMode )
|
||||||
bool KIPLATFORM::IO::DuplicatePermissions( const wxString &aSrc, const wxString &aDest )
|
bool KIPLATFORM::IO::DuplicatePermissions( const wxString &aSrc, const wxString &aDest )
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
PSECURITY_DESCRIPTOR pSD = nullptr;
|
|
||||||
DWORD dwSize = 0;
|
DWORD dwSize = 0;
|
||||||
|
|
||||||
// Retrieve the security descriptor from the source file
|
// Retrieve the security descriptor from the source file
|
||||||
if( GetFileSecurity( sourceFilePath.wc_str(),
|
if( GetFileSecurity( aSrc.wc_str(),
|
||||||
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
|
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
|
||||||
NULL, 0, &dwSize ) )
|
NULL, 0, &dwSize ) )
|
||||||
{
|
{
|
||||||
pSD = static_cast<PSECURITY_DESCRIPTOR>( new BYTE[dwSize] );
|
#ifdef __MINGW32__
|
||||||
|
// pSD is used as PSECURITY_DESCRIPTOR, aka void* pointer
|
||||||
|
// it create an annoying warning on gcc with "delete[] pSD;" :
|
||||||
|
// "warning: deleting 'PSECURITY_DESCRIPTOR' {aka 'void*'} is undefined"
|
||||||
|
// so use a BYTE* pointer (do not cast it to a void pointer)
|
||||||
|
BYTE* pSD = new BYTE[dwSize];
|
||||||
|
#else
|
||||||
|
PSECURITY_DESCRIPTOR pSD = static_cast<PSECURITY_DESCRIPTOR>( new BYTE[dwSize] );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( !pSD )
|
if( !pSD )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( !GetFileSecurity( sourceFilePath.wc_str(),
|
if( !GetFileSecurity( aSrc.wc_str(),
|
||||||
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
|
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
|
||||||
| DACL_SECURITY_INFORMATION, pSD, dwSize, &dwSize ) )
|
| DACL_SECURITY_INFORMATION, pSD, dwSize, &dwSize ) )
|
||||||
{
|
{
|
||||||
|
@ -95,7 +102,7 @@ bool KIPLATFORM::IO::DuplicatePermissions( const wxString &aSrc, const wxString
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the retrieved security descriptor to the destination file
|
// Assign the retrieved security descriptor to the destination file
|
||||||
if( !SetFileSecurity( destFilePath.wc_str(),
|
if( !SetFileSecurity( aDest.wc_str(),
|
||||||
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
|
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
|
||||||
| DACL_SECURITY_INFORMATION, pSD ) )
|
| DACL_SECURITY_INFORMATION, pSD ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ FILE* KIPLATFORM::IO::SeqFOpen( const wxString& aPath, const wxString& aMode )
|
||||||
return wxFopen( aPath, aMode );
|
return wxFopen( aPath, aMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssignPermissions(const wxString& sourceFilePath, const wxString& destFilePath)
|
bool KIPLATFORM::IO::DuplicatePermissions(const wxString& sourceFilePath, const wxString& destFilePath)
|
||||||
{
|
{
|
||||||
NSString *sourcePath = [NSString stringWithUTF8String:sourceFilePath.utf8_str()];
|
NSString *sourcePath = [NSString stringWithUTF8String:sourceFilePath.utf8_str()];
|
||||||
NSString *destPath = [NSString stringWithUTF8String:destFilePath.utf8_str()];
|
NSString *destPath = [NSString stringWithUTF8String:destFilePath.utf8_str()];
|
||||||
|
@ -47,16 +47,16 @@ bool AssignPermissions(const wxString& sourceFilePath, const wxString& destFileP
|
||||||
|
|
||||||
NSNumber *permissions = sourceAttributes[NSFilePosixPermissions];
|
NSNumber *permissions = sourceAttributes[NSFilePosixPermissions];
|
||||||
|
|
||||||
if (permissions == nil)
|
if (permissions == nil)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([fileManager setAttributes:@{NSFilePosixPermissions: permissions} ofItemAtPath:destPath error:&error])
|
if ([fileManager setAttributes:@{NSFilePosixPermissions: permissions} ofItemAtPath:destPath error:&error])
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"Error assigning permissions: %@", error);
|
NSLog(@"Error assigning permissions: %@", error);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue