Skip to content

Commit

Permalink
Merge pull request #1862 from AllenInstitute/bugfix/1862-get-all-file…
Browse files Browse the repository at this point in the history
…s-backport
  • Loading branch information
t-b authored Aug 31, 2023
2 parents 3b57f12 + e84561d commit 7f1594e
Show file tree
Hide file tree
Showing 3 changed files with 38 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
35 changes: 35 additions & 0 deletions Packages/tests/Basic/UTF_Utils.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -7202,3 +7202,38 @@ 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/C/Z $symbPath, folder
CHECK(!V_Flag)

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 7f1594e

Please sign in to comment.