Re: OS.FileSys and recursive procedures ?
brian denheyer <briand-/[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
Hi John,
Thanks for responding.
Yes I am sure that I do. I am the owner and the group and have
necessary permissions.
I checked by cd'ing into the particular directory as a test.
However that was an good point, so I investigated further and have
found the
problem, but the symptoms are quite bizarre.
I did the following sequence in the SML REPL :
val a= openDir(".")
val b= readDir(a)
val c = openDir(valOf(b))
etc..
It failed also !
Keep in mind that I am leaving previous openDir's open, i.e. there
are several openDir's active at once, even though they are not being
used.
I then tried this on a second directory and it succeeded ???
So I went back to the first directory. here is the directory structure:
. -> D1 -> D2 -> Files ...
-> D3 -> D4 -> Files ...
trying to execute openDir on D2 OR D4 is what fails. I stopped with
the 2 test
cases. So if I am in D1 to start then it works. This jives with the
fact that my
recursive loop also seems to fail when it descends on the directories.
At this point I'm completely lost. BTW, this is all 100% repeatable.
If you have any ideas I'm happy to try them out.
Brian
On Jan 22, 2006, at 9:22 PM, John Reppy wrote:
> Are you sure that you have read and execute permission on the
> directory in
> question?
>
> - John
>
> On Jan 22, 2006, at 11:06 PM, brian denheyer wrote:
>
>> The following function does not seem to work correctly :
>> (you'll need structure FS = OS.FileSys to make it run)
>>
>> fun loopDir(dir) =
>> (print "loopDir\n";
>> let val d = FS.readDir(dir)
>> in
>> case d of
>> NONE => (print "none\n";
>> FS.closeDir(dir))
>> | SOME s => (if FS.isDir(s) then
>> (print ("Dir:'"^s^"'\n");
>> print ("full path:"^FS.fullPath(s)
>> ^"\n");
>> loopDir(FS.openDir(s));
>> ())
>> else if FS.isLink(s) then
>> print ("Link:'"^s^"'\n")
>> else
>> (print ("File:"^s^"\n");
>> File(s));
>> loopDir(dir))
>>
>> end
>>
>> I start the loop with loopDir(FS.openDir("."))
>>
>> Eventually I get a file doesn't exist error !
>> Through the use of the prints I have identified that the val d =
>> statement is
>> failing with a "no such file or directory error".
>>
>> That's pretty much impossible as far as I can tell. Notice that
>> the openDir
>> has already been done and is being passed into the loop. The only
>> possible answers
>> are a file of some sort, or NONE, the openDir has already been
>> performed and the directory mus exist or the FS.isDir would not
>> have succeeded.
>>
>> It's definitely the recursive invocation which is causing
>> problems. In other words,
>> if I perform the readDir BEFORE recursively invoking the loop, it
>> is sucessful
>> and gives the expected results.
>>
>> This is on MAC OS X 10.4.4
>>
>> Thanks
>>
>> Brian
>>
>> P.S. Is this list still alive ? have not seen anything in a long
>> time...
>>
>>
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc. Do you grep through
>> log files
>> for problems? Stop! Download the new AJAX search engine that makes
>> searching your log files as easy as surfing the web. DOWNLOAD
>> SPLUNK!
>> http://sel.as-us.falkag.net/sel?
>> cmd=lnk&kid=103432&bid=230486&dat=121642
>> _______________________________________________
>> Smlnj-list mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/smlnj-list
>>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through
> log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD
> SPLUNK!
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Smlnj-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/smlnj-list
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642