MCPcopy Create free account
hub / github.com/bumptop/BumpTop / getDirectoryContents

Method getDirectoryContents

trunk/win/Source/BT_FileSystemManager.cpp:771–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769}
770
771StrList FileSystemManager::getDirectoryContents(QString dirPath, QString filter)
772{
773#ifdef WIN32
774 WIN32_FIND_DATA ffd;
775 vector<QString> listing;
776 HANDLE hFind = NULL;
777
778 // Return early if no directory
779 if (!isValidFileName(dirPath))
780 {
781 return listing;
782 }
783
784 if (!dirPath.endsWith("\\"))
785 {
786 // Add a slash to the end of the Path
787 dirPath.append("\\");
788 }
789
790 hFind = FindFirstFile((LPCTSTR) (dirPath + filter).utf16(), &ffd);
791 if (hFind != INVALID_HANDLE_VALUE)
792 {
793 do
794 {
795 // Add the filename to the list
796 bool isHidden = (ffd.dwFileAttributes & Hidden) > 0;
797 if (!isHidden || GLOBAL(settings).LoadHiddenFiles)
798 {
799 QString fileName = QString::fromUtf16((const ushort *) ffd.cFileName);
800 if (fileName != "." &&
801 fileName != "..")
802 {
803 listing.push_back(dirPath + fileName);
804 }
805 }
806 } while (FindNextFile(hFind, &ffd));
807
808 FindClose(hFind);
809 }
810
811 return listing;
812#else
813 vector<QString> fileListing;
814
815 QStringList filters;
816 filters << filter;
817 QDir directory(dirPath);
818 if (exists(directory))
819 {
820 directory.setNameFilters(filters);
821 directory.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
822 directory.setSorting(QDir::Name | QDir::DirsFirst);
823
824 QFileInfoList list = directory.entryInfoList();
825 for (int i = 0; i < list.size(); ++i)
826 {
827 fileListing.push_back(native(list[i]));
828 }

Callers 15

onStateChangedMethod · 0.80
onStateChangedMethod · 0.80
reloadDefaultThemeMethod · 0.80
pileizeMethod · 0.80
onStateChangedMethod · 0.80
crossReferenceMethod · 0.80
onCommandMethod · 0.80
HandleDoubleClickFunction · 0.80
updateDirectoryMethod · 0.80
GetIconPositionsMethod · 0.80

Calls 6

existsFunction · 0.70
nativeFunction · 0.70
endsWithMethod · 0.45
appendMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by 4

onStateChangedMethod · 0.64
onStateChangedMethod · 0.64
onStateChangedMethod · 0.64
onStateChangedMethod · 0.64