File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -113,18 +113,31 @@ std::vector<std::string> get_files_from_dir(const std::string& dir) {
113113
114114 // Find the first file in the directory
115115 hFind = FindFirstFile (directoryPath, &findFileData);
116-
116+ bool isAbsolutePath = false ;
117117 // Check if the directory was found
118118 if (hFind == INVALID_HANDLE_VALUE) {
119- printf (" Unable to find directory.\n " );
120- return files;
119+ printf (" Unable to find directory. Try with original path \n " );
120+
121+ char directoryPathAbsolute[MAX_PATH];
122+ sprintf (directoryPathAbsolute, " %s*" , dir.c_str ());
123+
124+ hFind = FindFirstFile (directoryPathAbsolute, &findFileData);
125+ isAbsolutePath = true ;
126+ if (hFind == INVALID_HANDLE_VALUE) {
127+ printf (" Absolute path was also wrong.\n " );
128+ return files;
129+ }
121130 }
122131
123132 // Loop through all files in the directory
124133 do {
125134 // Check if the found file is a regular file (not a directory)
126135 if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
127- files.push_back (std::string (currentDirectory) + " \\ " + dir + " \\ " + std::string (findFileData.cFileName ));
136+ if (isAbsolutePath) {
137+ files.push_back (dir + " \\ " + std::string (findFileData.cFileName ));
138+ } else {
139+ files.push_back (std::string (currentDirectory) + " \\ " + dir + " \\ " + std::string (findFileData.cFileName ));
140+ }
128141 }
129142 } while (FindNextFile (hFind, &findFileData) != 0 );
130143
You can’t perform that action at this time.
0 commit comments