Skip to content

Commit

Permalink
GetAllFilesRecursivelyFromPath: Fix returning empty results at the end
Browse files Browse the repository at this point in the history
Since the bugfix in 3b9e1c5 (bugfix: GetAllFilesRecursivelyFromPath use
reliable name retrieval, 2023-05-22) the list of returned files contained
an empty entry at the end.

Remove that and also add tests.
  • Loading branch information
t-b committed Aug 29, 2023
1 parent 2f387be commit 02e6222
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ CheckIfConfigurationRestoresMCCFilterGain.json

# Renamed experiments during tests
Packages/tests/**/20*.pxp

Packages/tests/Basic/test*
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_Utilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2867,7 +2867,7 @@ Function/S GetAllFilesRecursivelyFromPath(pathName, [extension])
KillPath/Z $subFolderPathName

if(!isEmpty(files))
allFiles = AddListItem(files, allFiles, FILE_LIST_SEP, Inf)
allFiles = AddListItem(RemoveEnding(files, FILE_LIST_SEP), allFiles, FILE_LIST_SEP, Inf)
endif
endfor

Expand Down
34 changes: 34 additions & 0 deletions Packages/tests/Basic/UTF_Utils.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -7202,3 +7202,37 @@ static Function TestUpperCaseFirstChar()
CHECK_EQUAL_STR(UpperCaseFirstChar("a1a"), "A1a")
CHECK_EQUAL_STR(UpperCaseFirstChar("b"), "B")
End

static Function TestGetAllFilesRecursivelyFromPath()

string folder, symbPath, list

folder = GetFolder(FunctionPath("")) + "testFolder:"

symbPath = GetUniqueSymbolicPath()
NewPath/Q/O $symbPath, folder

CreateFolderOnDisk(folder + "b:")
CreateFolderOnDisk(folder + "c:")

SaveTextFile("", folder + "file.txt")
SaveTextFile("", folder + "b:file1.txt")
SaveTextFile("", folder + "c:file2.txt")

CreateAliasShortcut/Z/P=$symbPath "file.txt" "alias.txt"
CHECK(!V_flag)

list = GetAllFilesRecursivelyFromPath(symbPath, extension = ".txt")
CHECK_PROPER_STR(list)

WAVE/T result = ListToTextWave(list, FILE_LIST_SEP)
result[] = RemovePrefix(result[p], start = folder)
CHECK_EQUAL_TEXTWAVES(result, {"file.txt", "b:file1.txt", "c:file2.txt"})

// no matches
list = GetAllFilesRecursivelyFromPath(symbPath, extension = ".abc")
CHECK_EMPTY_STR(list)

KillPath $symbPath
CHECK_NO_RTE()
End

0 comments on commit 02e6222

Please sign in to comment.