Tk Library Source Code

View Ticket
Login
Ticket UUID: 1111153
Title: fileutil::findByPattern fails during recursive search on XP.
Type: Bug Version: None
Submitter: pfinnegan Created on: 2005-01-28 00:43:56
Subsystem: fileutil Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2005-02-02 13:49:56
Resolution: Duplicate Closed By: andreas_kupries
    Closed on: 2005-02-02 06:49:56
Description:
fileutil::findByPattern fails during recursive search on 
Windows XP.     


() 143 % set fileList [ fileutil::findByPattern c:\\ * ]
couldn't change working directory to "sys": no such file 
or directory
(bind) 144 % 

bin) 74 % fileutil::findByPattern c:/ *
couldn't change working directory to "sys": no such file 
or directory
(bind) 75 % 

Stack trace. 

couldn't change working directory to "sys": no such file 
or directory
    while executing
"cd $basedir"
    (procedure "find" line 12)
    invoked from within
"find $filename $filtercmd"
    (procedure "find" line 34)
    invoked from within
"find $filename $filtercmd"
    (procedure "find" line 34)
    invoked from within
"find $filename $filtercmd"
    (procedure "find" line 34)
    invoked from within
"find $filename $filtercmd"
    (procedure "find" line 34)
    invoked from within
"find $filename $filtercmd"
    (procedure "find" line 34)
    invoked from within
"find $filename $filtercmd"
    (procedure "find" line 34)
    invoked from within
"find $basedir [list $cmd $patterns]"
    (procedure "fileutil::findByPattern" line 23)
    invoked from within
"fileutil::findByPattern c:\\ * "
    invoked from within
"set fileList [ fileutil::findByPattern c:\\ * ]"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 {set fileList [ fileutil::findByPattern c:\\ * ]}"
User Comments: andreas_kupries added on 2005-02-02 13:49:56:
Logged In: YES 
user_id=75003

Change using [catch] committed to head.

andreas_kupries added on 2005-02-02 13:48:29:
Logged In: YES 
user_id=75003

Looking over the other bugs I find that this one is actually
a duplicate of
http://sourceforge.net/support/tracker.php?aid=862491

See there for more discussion which was had on the Tcler's chat.
I have decided to fix this with a catch, ignoring any
problematic directories. I will also file an RFE asking for
an API change which allows us to set an error handler, to be
called for the problematic directories.

andreas_kupries added on 2005-02-02 13:13:09:
Logged In: YES 
user_id=75003

Small correction: The 'sys' directory itself will appear in
the output of 'find', and of 'findByPatttern', if matching
the pattern. Files and directories under 'sys' will not.

andreas_kupries added on 2005-02-02 13:06:08:
Logged In: YES 
user_id=75003

The only other thing I can think of is that the permissions
of the directory prevent you from entering it. The error
message however is evidence against that. Still, I cannot
exclude this, i.e. maybe the error message given by Windows
is wrong.

Well, I just tried this on Linux with a directory I made
inaccessible (chmod -x). And an attempt to cd into that
directory, in tclsh, returned the message "file or directory
does not exist", but 'file isdir' and 'file isfile' returned
the proper information. This is an indicator that
permissions can be the problem as well. ... And 'find'
errors out in the same manner as demonstrated.

This would however not change the fix. The unix 'find'
command ignores inaccessible directories, and we can do the
same.

andreas_kupries added on 2005-02-02 12:56:29:
Logged In: YES 
user_id=75003

It is fileutil::find which has the problem, not
findByPattern. findByPattern is implemented in terms of 'find'.

'find' calls itself recursively for all directories it finds
in the base directory, making the subdirectory the new base
directory.

Looking at the code of 'find' it further seems to me that
the 'glob' command is listing 'sys' deeply somewhere under
c:\, 'file isfile' claims that it is not a file, but 'file
isdirectory' claims that it is a directory. In complete
contrast to the error message returned by 'cd'.

The only time I have remotely similar behaviour, i.e.
completely conflicting information from the various
subcommands of the 'file' command, 'cd', 'glob', and the
like was for a system file, in my case 'page.sys'.

Given the name of the directory my guess is that this is a
special directory of Windows which looks like a directory,
behaves like directory, and yet is not a directory, not even
there. To regular file/dir commands.

My plan for fixing this is to add a catch around the 'cd
$basedir' which errors out, and to ignore the
pseudo-directory. In other words, neither sys, nor anything
inside of it would show up in the out of 'find',
'findByPattern', ever.

One thing might wish to try in the interim is to locate this
'sys' directory by conventional means, i.e. MS Explorer, and
then to run various file related commands of Tcl on it, like
'file exists', 'file isdir', 'file attributes', 'glob',
'cd', etc.