@@ -237,7 +237,11 @@ Function/S GetAllFilesRecursivelyFromPath(string pathName, [string extension])
237237 string files, allFilesList
238238 string allFiles = ""
239239 string foldersFromAlias = ""
240- variable err
240+ variable err, isWindows
241+
242+ #ifdef WINDOWS
243+ isWindows = 1
244+ #endif // WINDOWS
241245
242246 PathInfo $ pathName
243247 ASSERT ( V_flag, "Given symbolic path does not exist" )
@@ -248,27 +252,47 @@ Function/S GetAllFilesRecursivelyFromPath(string pathName, [string extension])
248252
249253 AssertOnAndClearRTError ()
250254 allFilesList = IndexedFile ( $ pathName, -1, extension, "????" , FILE_LIST_SEP) ; err = GetRTError ( 1 )
251- WAVE /T allFilesInDir = ListToTextWave ( allFilesList, FILE_LIST_SEP)
252- for ( fileName : allFilesInDir)
253-
254- fileOrPath = ResolveAlias ( fileName, pathName = pathName)
255-
256- if ( isEmpty ( fileOrPath))
257- // invalid shortcut, try next file
258- continue
259- endif
260-
261- GetFileFolderInfo / P=$ pathName/ Q/ Z fileOrPath
262- ASSERT ( ! V_Flag, "Error in GetFileFolderInfo" )
263255
264- if ( V_isFile)
265- allFiles = AddListItem ( S_path, allFiles, FILE_LIST_SEP, Inf )
266- elseif ( V_isFolder)
267- foldersFromAlias = AddListItem ( S_path, foldersFromAlias, FILE_LIST_SEP, Inf )
268- else
269- ASSERT ( 0, "Unexpected file type" )
270- endif
271- endfor
256+ if ( isWindows && cmpstr ( extension, "????" ) && cmpstr ( extension, ".lnk" ))
257+ allFiles = AddPrefixToEachListItem ( S_path, allFilesList, sep = FILE_LIST_SEP)
258+ else
259+ // try to resolve aliases/shortcuts when we can have them
260+ WAVE /T allFilesInDir = ListToTextWave ( allFilesList, FILE_LIST_SEP)
261+ for ( fileName : allFilesInDir)
262+
263+ GetFileFolderInfo / P=$ pathName/ Q/ Z fileName
264+
265+ if ( V_Flag != 0 )
266+ // error querying file
267+ continue
268+ endif
269+
270+ if ( V_IsAliasShortcut)
271+ fileOrPath = ResolveAlias ( fileName, pathName = pathName)
272+
273+ if ( IsEmpty ( fileOrPath))
274+ // dead alias
275+ continue
276+ endif
277+
278+ // redo the check
279+ GetFileFolderInfo / P=$ pathName/ Q/ Z fileOrPath
280+
281+ if ( V_Flag != 0 )
282+ // error querying file/folder pointed to by alias
283+ continue
284+ endif
285+ endif
286+
287+ if ( V_isFile)
288+ allFiles = AddListItem ( S_path, allFiles, FILE_LIST_SEP, Inf )
289+ elseif ( V_isFolder)
290+ foldersFromAlias = AddListItem ( S_path, foldersFromAlias, FILE_LIST_SEP, Inf )
291+ else
292+ ASSERT ( 0, "Unexpected file type" )
293+ endif
294+ endfor
295+ endif
272296
273297 AssertOnAndClearRTError ()
274298 folders = IndexedDir ( $ pathName, -1, 1, FILE_LIST_SEP) ; err = GetRTError ( 1 )
0 commit comments