On Sat, Nov 23, 2013 at 12:35 PM, Mark Miesfeld <miesfeld@gmail.com> wrote:
On Sat, Nov 23, 2013 at 12:19 PM, Mike Cowlishaw <mfc@speleotrove.com> wrote:
 
I've got a fix for this for stream query exists, but could you take a look at the sysfiletree problem?  I'm not convinced this is actually a bug, but a quirk of how FindFirstFile works on Windows with wildcard characters.   The stream query exists problem was occurring because FindFirstFile was being used to verify the existence, using an already fully qualified name. 

For SysFileTree() this is definitely the result of how FindFirstFile() works.  It is documented as a bug, although the Microsoft link seems to have been lost.  There is information on it here:

http://onsec.ru/onsec.whitepaper-02.eng.pdf

The pattern used in the me.rex example sent to SysFileTree is:   *.?<>*

The white paper referenced above explains that FindFirstFile substitutes * for any < character and ? for any > character.

So the pattern used becomes essentially:  *.?*?*

Me expectation is that SysFileTree returns the same results as dir:

C:\temp\test>dir *.?*?*
 Volume in drive C is Win7
 Volume Serial Number is D25E-50D5

 Directory of C:\temp\test

11/23/2013  01:06 PM    <DIR>          .
11/23/2013  01:06 PM    <DIR>          ..
11/23/2013  01:15 PM               465 me.rex
11/23/2013  12:39 PM               421 me.rexx
               2 File(s)            886 bytes
               2 Dir(s)   1,848,860,672 bytes free

C:\temp\test>

So, the results are to be expected when one knows about the FindFirstFile behaviour.
 

 Definitely a place  to tread with care ...my isDir and isFile routines go through some 'hoops'   ... suggest we discuss if any changes planned.



The bug itself was opened in relation to SysFileTree on Windows.  I don't know how this plays out on Linux, but as I recall Linux file systems do not really have illegal characters except the slash  and null.  So, I don't think it is much of a problem except on Windows

I see 3 possible changes:

1.)  Add to the doc that if you use illegal characters in the pattern, your results are undefined.

2.)  Check the pattern and if illegal characters are present set stem.0 to 0 and return an error code.

3.) Check the pattern for illegal characters and if present raise a syntax condition.

For myself, I prefer 3, because if I'm writing Rexx code I always test the program before real use and prefer a syntax condition so I immediately know I have to fix something before I am finished testing.

Mike and Rick probably prefer 1 or 2.

--
Mark Miesfeld