Hi,
If you see DEFINITION of DIR[""] and DIR["*"] below it suggests there
should be some difference.
But if I run the CODE below I find they produce exactly the same output.
Is my documentation wrong or what am I doing wrong?
What would you think ’ Matches subdirectories recursively’ means?
Cheers, Mike
CODE
list = Dir["**"]
list.sort!
puts(list)
list = Dir["*"]
list.sort!
puts(list)
##########
DEFINITION
##########
Dir[ aString ] -> anArray
Returns anArray of filenames found by expanding the pattern given in
aString. Note that this pattern is not a regexp (it’s closer to a shell
glob) and may contain the following metacharacters:
** Matches subdirectories recursively
Matches zero or more characters
? Matches any single character
[ charSet ] Matches any character from the given set of characters. A
range of characters is written as charFrom-charTo. The set may be
negated with an initial uparrow (^).
{ opt, opt, … } Matches any one of the optional strings
##########
[ charSet ] Matches any character from the given set of characters. A
range of characters is written as charFrom-charTo. The set may be
negated with an initial uparrow (^).
{ opt, opt, … } Matches any one of the optional strings
? Matches any single character
[ charSet ] Matches any character from the given set of characters. A
range of characters is written as charFrom-charTo. The set may be
negated with an initial uparrow (^).
{ opt, opt, … } Matches any one of the optional strings
Cheers, Mike
list.sort!
glob) and may contain the following metacharacters:
Try Dir[’**/*’], it only applies this way.
T.
using “/*" doesn’t seem to get all dirs, it misses the hidden ones
do you know the logic behind "/" or "/" ?
Cheers Mike
The convention in file globbing is always to ignore the hidden files,
unless explicitly stated otherwise.
Also, the documentation explicitly says that “**” match recursively the
/directories/, when "” match any /files/.
But looking at the documentation, and mainly this bit:
Make me wonder if anybody had proposed to use the operator / for joining
files component.
A recent addition to Python is a class that inherit string but with all
the facilities for paths (i.e. globbing, listing, joining, …) and I
must say it is very convenient. The previous two lines could be written
something like:
? Matches any single character
[ charSet ] Matches any character from the given set of characters. A
range of characters is written as charFrom-charTo. The set may be
negated with an initial uparrow (^).
{ opt, opt, … } Matches any one of the optional strings
Try Dir[’**/*’], it only applies this way.
T.
using “/*" doesn’t seem to get all dirs, it misses the hidden ones
do you know the logic behind "/" or "/*” ?
Cheers Mike