Chdir problem
Fairlight
fairlite at fairlite.com
Wed Sep 1 01:01:21 PDT 2004
Yo, homey, in case you don' be listenin', GCC Consulting done said:
> Thanks mark,
>
> Both you and Ken suggested the same approach. The file type is ASCII for
> 997.rpt.
You're missing my particular point about the file types. You were talking
about "walking" through directories (what many of us call traversal).
Thing is, I assumed you'd be doing a full traversal, meaning you'd
be pulling the entire list of files in a directory, and entering any
subdirectories to check for the presence of said file there, checking
through a whole tree recursively.
The way to do that conventionally is to test whether a 'file' is a
directory or not. Actually, it's whether the inode references a file or
directory, but let's not get hung up on semantics. That information would
ordinarily be in st_mode as a prefix before the last four characters that
dictates what the mode of the file is. If you convert the value to octal
notation that you'd use with chmod, you'd see a file read "10644" and a
directory read "40755". Of course, an executable could be 10755, so you
really need those first bytes (there can be more than one...I think there
are two, actually).
Those values were for *nix. I just remembered you're on 'doze. Okay,
having tested quickly...
On Windows, the definitions are a bit different. The results I'm seeing
indicate that files go "10xxxx" and directories go "4xxxx", where 'xxxx'
are the actual permissions (win95 is giving me nothing but 0666 and 0777,
imagine that).
In *nix, 'test' or a Bourne-esque shell, or perl, or even csh, when using
the -d test you would determine this without you having to look at it raw.
I use that day in and day out. Only once can I recall actually looking
at the raw file type in the mode element in perl, and that was to tell
something very obscure--like whether a file was a socket. I used to have
to do it in C though.
Unfortunately, -all- of that is missing in fP because there is no -d and
the leading bytes of the octal representation of the mode element of the
inode structure are stripped off.
So unless there's a -safe- way to test (Ken, does OPENDIR fail safely and
testably if you try it on a non-directory?), then there's no way to know
which files you should be traversing into because they're directory inodes.
That, or as has been the case before, someone will come up with a function
that's been added between 4.1 and 5.x that I just don't know about, and
it'll be called something like ISDIR(), and I'll be eating crow tomorrow.
But if there is such a function in fP, I'm honestly not aware of it.
> My head isn't quite in to programming as I have to go back in for some
> more surgery on Sept 7th.
Ouch on the surgery. Godspeed, good luck, and be well, Richard.
mark->
--
Bring the web-enabling power of OneGate to -your- filePro applications today!
Try the live filePro-based, OneGate-enabled demo at the following URL:
http://www2.onnik.com/~fairlite/flfssindex.html
More information about the Filepro-list
mailing list