Don't show hidden directories and files in the project tree browser
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16207
(cherry picked from commit 5cdf9fe8a0
)
4b9fffa3 Don't show hidden directories and hidden files in the Project tree browser
c433874c Changed file name conversation to utf16
aeba54ba Moved os-specific function to lib KIPLATFORM::IO
561709ac Implemented KIPLATFORM::IO::IsFileHidden for all plattforms
This commit is contained in:
parent
e765de6b3d
commit
64f8310a94
|
@ -78,6 +78,8 @@
|
|||
#include "project_tree_pane.h"
|
||||
#include <widgets/kistatusbar.h>
|
||||
|
||||
#include <kiplatform/io.h>
|
||||
|
||||
|
||||
/* Note about the project tree build process:
|
||||
* Building the project tree can be *very* long if there are a lot of subdirectories in the
|
||||
|
@ -392,12 +394,8 @@ wxTreeItemId PROJECT_TREE_PANE::addItemToProjectTree( const wxString& aName,
|
|||
TREE_FILE_TYPE type = TREE_FILE_TYPE::UNKNOWN;
|
||||
wxFileName fn( aName );
|
||||
|
||||
#ifndef __WXMSW__
|
||||
// Files/dirs names starting by "." are not visible files under unices (including MacOS),
|
||||
// but are under MSW.
|
||||
if( fn.GetName().StartsWith( wxT( "." ) ) )
|
||||
if( KIPLATFORM::IO::IsFileHidden( aName ) )
|
||||
return wxTreeItemId();
|
||||
#endif
|
||||
|
||||
if( wxDirExists( aName ) )
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <wx/crt.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -58,3 +59,10 @@ bool KIPLATFORM::IO::DuplicatePermissions( const wxString &aSrc, const wxString
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool KIPLATFORM::IO::IsFileHidden( const wxString& aFileName )
|
||||
{
|
||||
wxFileName fn( aFileName );
|
||||
|
||||
return fn.GetName().StartsWith( wxT( "." ) );
|
||||
}
|
||||
|
|
|
@ -44,6 +44,12 @@ namespace IO
|
|||
* @return true if the process was successful
|
||||
*/
|
||||
bool DuplicatePermissions( const wxString& aSrc, const wxString& aDest );
|
||||
|
||||
/**
|
||||
* Helper function to determine the status of the 'Hidden' file attribute.
|
||||
* @return true if the file attribut is set.
|
||||
*/
|
||||
bool IsFileHidden( const wxString& aFileName );
|
||||
} // namespace IO
|
||||
} // namespace KIPLATFORM
|
||||
|
||||
|
|
|
@ -114,3 +114,13 @@ bool KIPLATFORM::IO::DuplicatePermissions( const wxString &aSrc, const wxString
|
|||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool KIPLATFORM::IO::IsFileHidden( const wxString& aFileName )
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if( ( GetFileAttributesW( aFileName.fn_str() ) & FILE_ATTRIBUTE_HIDDEN ) )
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <wx/crt.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
FILE* KIPLATFORM::IO::SeqFOpen( const wxString& aPath, const wxString& aMode )
|
||||
{
|
||||
|
@ -62,4 +63,11 @@ bool KIPLATFORM::IO::DuplicatePermissions(const wxString& sourceFilePath, const
|
|||
NSLog(@"Error assigning permissions: %@", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool KIPLATFORM::IO::IsFileHidden( const wxString& aFileName )
|
||||
{
|
||||
wxFileName fn( aFileName );
|
||||
|
||||
return fn.GetName().StartsWith( wxT( "." ) );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue