mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-02 00:26:45 +00:00
Add a function to create long paths on windows
This commit is contained in:
parent
ccbce7e2ee
commit
41d7711f06
@ -23,6 +23,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
class wxString;
|
||||
class wxFileName;
|
||||
|
||||
namespace KIPLATFORM
|
||||
{
|
||||
@ -50,6 +51,12 @@ namespace IO
|
||||
* @return true if the file attribut is set.
|
||||
*/
|
||||
bool IsFileHidden( const wxString& aFileName );
|
||||
|
||||
/**
|
||||
* Adjusts a filename to be a long path compatible.
|
||||
* This is a no-op on non-Windows platforms.
|
||||
*/
|
||||
void LongPathAdjustment( wxFileName& aFilename );
|
||||
} // namespace IO
|
||||
} // namespace KIPLATFORM
|
||||
|
||||
|
@ -49,16 +49,16 @@ bool KIPLATFORM::IO::DuplicatePermissions(const wxString& sourceFilePath, const
|
||||
|
||||
NSNumber *permissions = sourceAttributes[NSFilePosixPermissions];
|
||||
|
||||
if (permissions == nil)
|
||||
if (permissions == nil)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ([fileManager setAttributes:@{NSFilePosixPermissions: permissions} ofItemAtPath:destPath error:&error])
|
||||
if ([fileManager setAttributes:@{NSFilePosixPermissions: permissions} ofItemAtPath:destPath error:&error])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Error assigning permissions: %@", error);
|
||||
return false;
|
||||
@ -71,3 +71,9 @@ bool KIPLATFORM::IO::IsFileHidden( const wxString& aFileName )
|
||||
|
||||
return fn.GetName().StartsWith( wxT( "." ) );
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::IO::LongPathAdjustment( wxFileName& aFilename )
|
||||
{
|
||||
// no-op
|
||||
}
|
@ -66,3 +66,9 @@ bool KIPLATFORM::IO::IsFileHidden( const wxString& aFileName )
|
||||
|
||||
return fn.GetName().StartsWith( wxT( "." ) );
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::IO::LongPathAdjustment( wxFileName& aFilename )
|
||||
{
|
||||
// no-op
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <wx/wxcrt.h>
|
||||
|
||||
#include <wx/filename.h>
|
||||
#include <windows.h>
|
||||
|
||||
// Define USE_MSYS2_FALlBACK if the code for _MSC_VER does not compile on msys2
|
||||
@ -123,4 +123,24 @@ bool KIPLATFORM::IO::IsFileHidden( const wxString& aFileName )
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void KIPLATFORM::IO::LongPathAdjustment( wxFileName& aFilename )
|
||||
{
|
||||
// dont shortcut this for shorter lengths as there are uses like directory
|
||||
// paths that exceed the path length when you start traversing their subdirectories
|
||||
// so we want to start with the long path prefix all the time
|
||||
|
||||
if( aFilename.GetVolume().Length() == 1 )
|
||||
// assume single letter == drive volume
|
||||
aFilename.SetVolume( "\\\\?\\" + aFilename.GetVolume() + ":" );
|
||||
else if( aFilename.GetVolume().Length() > 1
|
||||
&& aFilename.GetVolume().StartsWith( wxT( "\\\\" ) )
|
||||
&& !aFilename.GetVolume().StartsWith( wxT( "\\\\?\\" ) ) )
|
||||
// unc path aka network share, wx returns with \\ already
|
||||
// so skip the first slash and combine with the prefix
|
||||
// which in the case of UNCs is actually \\?\UNC\<server>\<share>
|
||||
// where UNC is literally the text UNC
|
||||
aFilename.SetVolume( "\\\\?\\UNC" + aFilename.GetVolume().Mid(1) );
|
||||
}
|
Loading…
Reference in New Issue
Block a user