MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / getFileNames

Method getFileNames

astyle/src/astyle_main.cpp:833–902  ·  view source on GitHub ↗

* WINDOWS function to resolve wildcards and recurse into sub directories. * The fileName vector is filled with the path and names of files to process. * * @param directory The path of the directory to be processed. * @param wildcard The wildcard to be processed (e.g. *.cpp). */

Source from the content-addressed store, hash-verified

831 * @param wildcard The wildcard to be processed (e.g. *.cpp).
832 */
833void ASConsole::getFileNames(const string &directory, const string &wildcard)
834{
835 vector<string> subDirectory; // sub directories of directory
836 WIN32_FIND_DATA findFileData; // for FindFirstFile and FindNextFile
837
838 // Find the first file in the directory
839 // Find will get at least "." and "..".
840 string firstFile = directory + "\\*";
841 HANDLE hFind = FindFirstFile(firstFile.c_str(), &findFileData);
842
843 if (hFind == INVALID_HANDLE_VALUE)
844 {
845 // Error (3) The system cannot find the path specified.
846 // Error (123) The filename, directory name, or volume label syntax is incorrect.
847 // ::FindClose(hFind); before exiting
848 displayLastError();
849 error(_("Cannot open directory"), directory.c_str());
850 }
851
852 // save files and sub directories
853 do
854 {
855 // skip hidden or read only
856 if (findFileData.cFileName[0] == '.'
857 || (findFileData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
858 || (findFileData.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
859 continue;
860
861 // is this a sub directory
862 if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
863 {
864 if (!isRecursive)
865 continue;
866 // if a sub directory and recursive, save sub directory
867 string subDirectoryPath = directory + g_fileSeparator + findFileData.cFileName;
868 if (isPathExclued(subDirectoryPath))
869 printMsg(_("Exclude %s\n"), subDirectoryPath.substr(mainDirectoryLength));
870 else
871 subDirectory.push_back(subDirectoryPath);
872 continue;
873 }
874
875 // save the file name
876 string filePathName = directory + g_fileSeparator + findFileData.cFileName;
877 // check exclude before wildcmp to avoid "unmatched exclude" error
878 bool isExcluded = isPathExclued(filePathName);
879 // save file name if wildcard match
880 if (wildcmp(wildcard.c_str(), findFileData.cFileName))
881 {
882 if (isExcluded)
883 printMsg(_("Exclude %s\n"), filePathName.substr(mainDirectoryLength));
884 else
885 fileName.push_back(filePathName);
886 }
887 }
888 while (FindNextFile(hFind, &findFileData) != 0);
889
890 // check for processing error

Callers

nothing calls this directly

Calls 1

statClass · 0.85

Tested by

no test coverage detected