-
-
Notifications
You must be signed in to change notification settings - Fork 641
! checking if each match found is either a file or folder appears to … #1850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -354,7 +354,7 @@ | |||||
| -- A table containing the matched file or directory names. | ||||||
| --- | ||||||
|
|
||||||
| function os.match(mask) | ||||||
| function os.match(mask, matchType) | ||||||
| mask = path.normalize(mask) | ||||||
| local starpos = mask:find("%*") | ||||||
| local before = path.getdirectory(starpos and mask:sub(1, starpos - 1) or mask) | ||||||
|
|
@@ -370,14 +370,14 @@ | |||||
|
|
||||||
| if recurse then | ||||||
| local submask = mask:sub(1, starpos) .. mask:sub(starpos + 2) | ||||||
| results = os.match(submask) | ||||||
| results = os.match(submask, matchType) | ||||||
|
|
||||||
| local pattern = mask:sub(1, starpos) | ||||||
| local m = os.matchstart(pattern) | ||||||
| while os.matchnext(m) do | ||||||
| if not os.matchisfile(m) then | ||||||
| local matchpath = path.join(before, os.matchname(m), mask:sub(starpos)) | ||||||
| results = table.join(results, os.match(matchpath)) | ||||||
| results = table.join(results, os.match(matchpath, matchType)) | ||||||
| end | ||||||
| end | ||||||
| os.matchdone(m) | ||||||
|
|
@@ -387,10 +387,17 @@ | |||||
| while os.matchnext(m) do | ||||||
| if not (slashpos and os.matchisfile(m)) then | ||||||
| local matchpath = path.join(before, matchpath, os.matchname(m)) | ||||||
|
|
||||||
| if after then | ||||||
| results = table.join(results, os.match(path.join(matchpath, after))) | ||||||
| results = table.join(results, os.match(path.join(matchpath, after), matchType)) | ||||||
| else | ||||||
| if matchType == "file" and os.matchisfile(m) then | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo? for below too
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not how
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, indeed, misread. |
||||||
| table.insert(results, matchpath) | ||||||
mihaisebea marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| elseif matchType == "folder" and not os.matchisfile(m) then | ||||||
| table.insert(results, matchpath) | ||||||
| else -- keep previous behaviour | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realised it's this here, it needs to check that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition the comment is not meaningful outside of the pull request. |
||||||
| table.insert(results, matchpath) | ||||||
| end | ||||||
| end | ||||||
| end | ||||||
| end | ||||||
|
|
@@ -412,12 +419,7 @@ | |||||
| --- | ||||||
|
|
||||||
| function os.matchdirs(mask) | ||||||
| local results = os.match(mask) | ||||||
| for i = #results, 1, -1 do | ||||||
| if not os.isdir(results[i]) then | ||||||
| table.remove(results, i) | ||||||
| end | ||||||
| end | ||||||
| local results = os.match(mask, "folder") | ||||||
| return results | ||||||
| end | ||||||
|
|
||||||
|
|
@@ -433,12 +435,7 @@ | |||||
| --- | ||||||
|
|
||||||
| function os.matchfiles(mask) | ||||||
| local results = os.match(mask) | ||||||
| for i = #results, 1, -1 do | ||||||
| if not os.isfile(results[i]) then | ||||||
| table.remove(results, i) | ||||||
| end | ||||||
| end | ||||||
| local results = os.match(mask, "file") | ||||||
| return results | ||||||
| end | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.