@@ -692,7 +692,7 @@ class FileSystemDirent : public IGFD::IFileSystem {
692692#ifdef _IGFD_WIN_
693693 auto filePath = vPath + ent->d_name ;
694694#else
695- auto filePath = vPath + std::string ( 1u , PATH_SEP ) + ent->d_name ;
695+ auto filePath = vPath + IGFD::Utils::GetPathSeparator ( ) + ent->d_name ;
696696#endif
697697 if (!stat (filePath.c_str (), &sb)) {
698698 if (sb.st_mode & S_IFLNK) {
@@ -905,6 +905,10 @@ size_t IGFD::Utils::GetLastCharPosWithMinCharCount(const std::string& vString, c
905905 return std::string::npos;
906906}
907907
908+ std::string IGFD::Utils::GetPathSeparator () {
909+ return std::string (1U , PATH_SEP);
910+ }
911+
908912#pragma endregion
909913
910914#pragma region FileStyle
@@ -1533,7 +1537,6 @@ bool IGFD::FileType::operator>(const FileType& rhs) const {
15331537bool IGFD::FileInfos::SearchForTag (const std::string& vTag) const {
15341538 if (!vTag.empty ()) {
15351539 if (fileNameExt_optimized == " .." ) return true ;
1536-
15371540 return fileNameExt_optimized.find (vTag) != std::string::npos || // first try without case and accents
15381541 fileNameExt.find (vTag) != std::string::npos; // second if searched with case and accents
15391542 }
@@ -1586,6 +1589,8 @@ bool IGFD::FileInfos::FinalizeFileTypeParsing(const size_t& vMaxDotToExtract) {
15861589 }
15871590 if (lpt != std::string::npos) {
15881591 size_t lvl = 0U ;
1592+ fileNameLevels[lvl] = fileNameExt.substr (0 , lpt);
1593+ fileNameLevels[lvl] = Utils::LowerCaseString (fileNameLevels[lvl]);
15891594 fileExtLevels[lvl] = fileNameExt.substr (lpt);
15901595 fileExtLevels_optimized[lvl] = Utils::LowerCaseString (fileExtLevels[lvl]);
15911596 if (countExtDot > 1U ) { // multi layer ext
@@ -1595,6 +1600,8 @@ bool IGFD::FileInfos::FinalizeFileTypeParsing(const size_t& vMaxDotToExtract) {
15951600 if (fileNameExt.size () > lpt) {
15961601 lpt = fileNameExt.find_first_of (' .' , lpt);
15971602 if (lpt != std::string::npos) {
1603+ fileNameLevels[lvl] = fileNameExt.substr (0 , lpt);
1604+ fileNameLevels[lvl] = Utils::LowerCaseString (fileNameLevels[lvl]);
15981605 fileExtLevels[lvl] = fileNameExt.substr (lpt);
15991606 fileExtLevels_optimized[lvl] = Utils::LowerCaseString (fileExtLevels[lvl]);
16001607 }
@@ -1612,7 +1619,7 @@ bool IGFD::FileInfos::FinalizeFileTypeParsing(const size_t& vMaxDotToExtract) {
16121619#pragma region FileManager
16131620
16141621IGFD::FileManager::FileManager () {
1615- fsRoot = std::string ( 1u , PATH_SEP );
1622+ fsRoot = IGFD::Utils::GetPathSeparator ( );
16161623 m_FileSystemName = typeid (FILE_SYSTEM_OVERRIDE).name ();
16171624 // std::make_unique is not available un cpp11
16181625 m_FileSystemPtr = std::unique_ptr<FILE_SYSTEM_OVERRIDE>(new FILE_SYSTEM_OVERRIDE ());
@@ -1793,6 +1800,19 @@ void IGFD::FileManager::m_SortFields(const FileDialogInternal& vFileDialogIntern
17931800 m_ApplyFilteringOnFileList (vFileDialogInternal, vFileInfosList, vFileInfosFilteredList);
17941801}
17951802
1803+ bool IGFD::FileManager::m_CompleteFileInfosWithUserFileAttirbutes (const FileDialogInternal& vFileDialogInternal, const std::shared_ptr<FileInfos>& vInfos) {
1804+ if (vFileDialogInternal.getDialogConfig ().userFileAttributes != nullptr ) {
1805+ if (!vFileDialogInternal.getDialogConfig ().userFileAttributes (vInfos.get (), vFileDialogInternal.getDialogConfig ().userDatas )) {
1806+ return false ; // the file will be ignored, so not added to the file list, so not displayed
1807+ } else {
1808+ if (!vInfos->fileType .isDir ()) {
1809+ vInfos->formatedFileSize = m_FormatFileSize (vInfos->fileSize );
1810+ }
1811+ }
1812+ }
1813+ return true ; // file will be added to file list, so displayed
1814+ }
1815+
17961816void IGFD::FileManager::ClearFileLists () {
17971817 m_FilteredFileList.clear ();
17981818 m_FileList.clear ();
@@ -1830,7 +1850,10 @@ void IGFD::FileManager::m_AddFile(const FileDialogInternal& vFileDialogInternal,
18301850 vFileDialogInternal.filterManager .m_FillFileStyle (infos);
18311851
18321852 m_CompleteFileInfos (infos);
1833- m_FileList.push_back (infos);
1853+
1854+ if (m_CompleteFileInfosWithUserFileAttirbutes (vFileDialogInternal, infos)) {
1855+ m_FileList.push_back (infos);
1856+ }
18341857}
18351858
18361859void IGFD::FileManager::m_AddPath (const FileDialogInternal& vFileDialogInternal, const std::string& vPath, const std::string& vFileName, const FileType& vFileType) {
@@ -1856,7 +1879,10 @@ void IGFD::FileManager::m_AddPath(const FileDialogInternal& vFileDialogInternal,
18561879 vFileDialogInternal.filterManager .m_FillFileStyle (infos);
18571880
18581881 m_CompleteFileInfos (infos);
1859- m_PathList.push_back (infos);
1882+
1883+ if (m_CompleteFileInfosWithUserFileAttirbutes (vFileDialogInternal, infos)) {
1884+ m_PathList.push_back (infos);
1885+ }
18601886}
18611887
18621888void IGFD::FileManager::ScanDir (const FileDialogInternal& vFileDialogInternal, const std::string& vPath) {
@@ -1868,7 +1894,7 @@ void IGFD::FileManager::ScanDir(const FileDialogInternal& vFileDialogInternal, c
18681894
18691895 if (!m_CurrentPathDecomposition.empty ()) {
18701896#ifdef _IGFD_WIN_
1871- if (path == fsRoot) path += std::string ( 1u , PATH_SEP );
1897+ if (path == fsRoot) path += IGFD::Utils::GetPathSeparator ( );
18721898#endif // _IGFD_WIN_
18731899
18741900 ClearFileLists ();
@@ -1887,7 +1913,7 @@ void IGFD::FileManager::m_ScanDirForPathSelection(const FileDialogInternal& vFil
18871913
18881914 if (!path.empty ()) {
18891915#ifdef _IGFD_WIN_
1890- if (path == fsRoot) path += std::string ( 1u , PATH_SEP );
1916+ if (path == fsRoot) path += IGFD::Utils::GetPathSeparator ( );
18911917#endif // _IGFD_WIN_
18921918
18931919 ClearPathLists ();
@@ -2069,7 +2095,9 @@ void IGFD::FileManager::m_CompleteFileInfos(const std::shared_ptr<FileInfos>& vI
20692095 std::string fpn;
20702096
20712097 // FIXME: so the condition is always true?
2072- if (vInfos->fileType .isFile () || vInfos->fileType .isLinkToUnknown () || vInfos->fileType .isDir ()) fpn = vInfos->filePath + std::string (1u , PATH_SEP) + vInfos->fileNameExt ;
2098+ if (vInfos->fileType .isFile () || vInfos->fileType .isLinkToUnknown () || vInfos->fileType .isDir ()) {
2099+ fpn = vInfos->filePath + IGFD::Utils::GetPathSeparator () + vInfos->fileNameExt ;
2100+ }
20732101
20742102 struct stat statInfos = {};
20752103 char timebuf[100 ];
@@ -2121,7 +2149,7 @@ void IGFD::FileManager::m_m_AddFileNameInSelection(const std::string& vFileName,
21212149void IGFD::FileManager::SetCurrentDir (const std::string& vPath) {
21222150 std::string path = vPath;
21232151#ifdef _IGFD_WIN_
2124- if (fsRoot == path) path += std::string ( 1u , PATH_SEP );
2152+ if (fsRoot == path) path += IGFD::Utils::GetPathSeparator ( );
21252153#endif // _IGFD_WIN_
21262154
21272155 bool dir_opened = m_FileSystemPtr->IsDirectory (path);
@@ -2153,7 +2181,7 @@ void IGFD::FileManager::SetCurrentDir(const std::string& vPath) {
21532181 IGFD::Utils::SetBuffer (inputPathBuffer, MAX_PATH_BUFFER_SIZE, m_CurrentPath);
21542182 m_CurrentPathDecomposition = IGFD::Utils::SplitStringToVector (m_CurrentPath, PATH_SEP, false );
21552183#ifdef _IGFD_UNIX_ // _IGFD_UNIX_ is _IGFD_WIN_ or APPLE
2156- m_CurrentPathDecomposition.insert (m_CurrentPathDecomposition.begin (), std::string ( 1u , PATH_SEP ));
2184+ m_CurrentPathDecomposition.insert (m_CurrentPathDecomposition.begin (), IGFD::Utils::GetPathSeparator ( ));
21572185#endif // _IGFD_UNIX_
21582186 if (!m_CurrentPathDecomposition.empty ()) {
21592187#ifdef _IGFD_WIN_
@@ -2166,7 +2194,7 @@ void IGFD::FileManager::SetCurrentDir(const std::string& vPath) {
21662194
21672195bool IGFD::FileManager::CreateDir (const std::string& vPath) {
21682196 if (!vPath.empty ()) {
2169- std::string path = m_CurrentPath + std::string ( 1u , PATH_SEP ) + vPath;
2197+ std::string path = m_CurrentPath + IGFD::Utils::GetPathSeparator ( ) + vPath;
21702198 return m_FileSystemPtr->CreateDirectoryIfNotExist (path);
21712199 }
21722200 return false ;
@@ -2178,7 +2206,7 @@ std::string IGFD::FileManager::ComposeNewPath(std::vector<std::string>::iterator
21782206 while (true ) {
21792207 if (!res.empty ()) {
21802208#ifdef _IGFD_WIN_
2181- res = *vIter + std::string ( 1u , PATH_SEP ) + res;
2209+ res = *vIter + IGFD::Utils::GetPathSeparator ( ) + res;
21822210#elif defined(_IGFD_UNIX_) // _IGFD_UNIX_ is _IGFD_WIN_ or APPLE
21832211 if (*vIter == fsRoot)
21842212 res = *vIter + res;
@@ -2239,14 +2267,14 @@ bool IGFD::FileManager::SelectDirectory(const std::shared_ptr<FileInfos>& vInfos
22392267 std::string newPath;
22402268
22412269 if (showDrives) {
2242- newPath = vInfos->fileNameExt + std::string ( 1u , PATH_SEP );
2270+ newPath = vInfos->fileNameExt + IGFD::Utils::GetPathSeparator ( );
22432271 } else {
22442272#ifdef __linux__
22452273 if (fsRoot == m_CurrentPath)
22462274 newPath = m_CurrentPath + vInfos->fileNameExt ;
22472275 else
22482276#endif // __linux__
2249- newPath = m_CurrentPath + std::string ( 1u , PATH_SEP ) + vInfos->fileNameExt ;
2277+ newPath = m_CurrentPath + IGFD::Utils::GetPathSeparator ( ) + vInfos->fileNameExt ;
22502278 }
22512279
22522280 if (m_FileSystemPtr->IsDirectoryCanBeOpened (newPath)) {
@@ -2365,7 +2393,7 @@ void IGFD::FileManager::DrawDirectoryCreation(const FileDialogInternal& vFileDia
23652393 if (IMGUI_BUTTON (okButtonString)) {
23662394 std::string newDir = std::string (directoryNameBuffer);
23672395 if (CreateDir (newDir)) {
2368- SetCurrentPath (m_CurrentPath + std::string ( 1u , PATH_SEP ) + newDir);
2396+ SetCurrentPath (m_CurrentPath + IGFD::Utils::GetPathSeparator ( ) + newDir);
23692397 OpenCurrentPath (vFileDialogInternal);
23702398 }
23712399
@@ -2488,7 +2516,7 @@ std::string IGFD::FileManager::GetResultingPath() {
24882516 std::string selectedDirectory = fileNameBuffer;
24892517 std::string path = m_CurrentPath;
24902518 if (!selectedDirectory.empty () && selectedDirectory != " ." ) {
2491- path += std::string ( 1u , PATH_SEP ) + selectedDirectory;
2519+ path += IGFD::Utils::GetPathSeparator ( ) + selectedDirectory;
24922520 }
24932521 return path;
24942522 }
@@ -2512,7 +2540,7 @@ std::string IGFD::FileManager::GetResultingFilePathName(FileDialogInternal& vFil
25122540 if (fsRoot != result)
25132541#endif // _IGFD_UNIX_
25142542 {
2515- result += std::string ( 1u , PATH_SEP );
2543+ result += IGFD::Utils::GetPathSeparator ( );
25162544 }
25172545 result += filename;
25182546 }
@@ -2530,7 +2558,7 @@ std::map<std::string, std::string> IGFD::FileManager::GetResultingSelection(File
25302558 if (fsRoot != result)
25312559#endif // _IGFD_UNIX_
25322560 {
2533- result += std::string ( 1u , PATH_SEP );
2561+ result += IGFD::Utils::GetPathSeparator ( );
25342562 }
25352563 result += vFileDialogInternal.filterManager .ReplaceExtentionWithCurrentFilterIfNeeded (selectedFileName, vFlag);
25362564 res[selectedFileName] = result;
@@ -2726,7 +2754,7 @@ void IGFD::ThumbnailFeature::m_ThreadThumbnailFileDatasExtractionFunc() {
27262754 {
27272755 // || file->fileExtLevels == ".hdr" => format float so in few times
27282756 if (file->SearchForExts (" .png,.bmp,.tga,.jpg,.jpeg,.gif,.psd,.pic,.ppm,.pgm" , true )) {
2729- auto fpn = file->filePath + std::string ( 1u , PATH_SEP ) + file->fileNameExt ;
2757+ auto fpn = file->filePath + IGFD::Utils::GetPathSeparator ( ) + file->fileNameExt ;
27302758
27312759 int w = 0 ;
27322760 int h = 0 ;
0 commit comments