CfsDirectoryDescriptor - differences between Windows and Linux

45 views
Skip to first unread message

jtu...@objektfabrik.de

unread,
Jun 12, 2012, 9:49:17 AM6/12/12
to va-sma...@googlegroups.com
Hi again,

I'm seeing differences between Windows and Linux in CfsDirectoryDescriptor.
I need to search for and list all existing files named "fadat*.txt" in a directory. The files are there.
On windows, the pattern 'fadat*.txt' brings up a list of files. On Linux, it doesn't. Changing the pattern to 'fadat*' brings up the list I'd expect (apart from the fact that .xls or .zip also are included in the list).

Is that a bug or expected behavior? The ls command on linux can handle fadat*.txt...

Here's the code I am using:

collection := OrderedCollection new.
(dd := CfsDirectoryDescriptor 
opendir: self currentDirectory
pattern: 'fadat*.txt'
mode: FREG | FDIR) isCfsError 
ifTrue: [self error: dd message].
[(de := dd readdir) notNil] whileTrue: [collection add: de].
dd closedir.
       collection inspect

Thanks for reading

Joachim

Douglas Swartz

unread,
Jun 13, 2012, 8:26:27 AM6/13/12
to va-sma...@googlegroups.com
Hello Joachim,

I don't have 8.5 handy, but this is a bug which I ran into years ago,
and I know exists until at least 8.0. Unfortunately, I never wrote it
up for Instantiations. I didn't even fix it, I just worked around it.

On Windows the file filtering is done in a windows API call by the OS.
On *nix it is done in the method
CfsDirectoryDescriptor>>basicReaddir:for:. The actual bug, I believe,
is in String>>indexOf:matchCase:startingAt:

For instance
'dummy.txt' indexOf: 'dumm*.txt' matchCase: true startingAt: 1.
returns Interval(1 2 3 4 5 6 7 8 9 )

but
'dummy.txt.txt' indexOf: 'dumm*.txt' matchCase: true startingAt: 1.
also returns Interval(1 2 3 4 5 6 7 8 9 )

Thus in the current *nix VAST, the file name dummy.txt matches
dumm*.txt, but dummy.txt.txt doesn't.

Doug Swartz
--
Best regards,
Douglas mailto:swartzco...@gmail.com

jtu...@objektfabrik.de

unread,
Jun 15, 2012, 3:24:05 PM6/15/12
to va-sma...@googlegroups.com
Doug,

funnily, the files we need to handle often end in *.txt.txt for some strange reasons. We get them from an external source so we cannot do anything about the strange naming.

So this is an (old) bug in String matching rather than in Cfs. Interesting... 
Has anyone at Instantiations had a chance to look into this?

Joachim
Reply all
Reply to author
Forward
0 new messages