SPUG: getting filesystem info? (a la File::Spec)
dancerboy
dancerboy at strangelight.com
Tue Nov 20 09:59:25 CST 2001
So, I'm trying to create a module that will, in effect, tell you
everything you could possibly want to know about how to construct
legal file- and path-names on the current filesystem. Specifically:
1) the directory-separator
2) maximum filename length
3) whether filenames are case-sensitive
4) if not, whether filenames are case-preserving (e.g. MacOS)
5) what characters are or are not legal in filenames
6) other restrictions on filenames (e.g. DOS filenames can have only a single
period, and the file extension after the period is limited to 3 characters)
Maybe some other things that I'm not thinking of at the moment.
File::Spec does some of this, but not all. I'd also like to do this
in a more platform-independent way than File::Spec (i.e., as much as
possible, I'd like the module to figure these things by directly
querying the OS/filesystem, rather than relying on a database of how
different OS's "should" behave. For one thing, remote volumes may
not behave as expected based on the local OS's filesystem
conventions.)
So, my questions are:
1) Does a module exist that already does this? I didn't see
anything on CPAN, but I confess my CPAN searches are not always
thorough (mostly because the cpan.org website is SLOW as F***. I
just don't have the patience to wait 5-minutes for each search
result... are there any good mirrors out there?)
2) Any suggestions for platform-independent ways of doing #1 and #6
from my list above?
3) Any suggestions for *better* ways of doing #2-5? My idea now is
simply to do a completely empirical test: attempting to create and
then stat a series of dummy files, whose names are generated so as to
discover the filesystem limitations as efficiently as possible.
4) Any other suggestions about what this module ought to do, or
issues that I'm not seeing? (I'm considering submitting this to CPAN
once I'm done...)
Some issues that I *am* aware of:
1) The main purpose of this module is to assist in the creation of
files in specific locations, so I'm not all that concerned with
volumes/directories which the current process cannot write to, for
whatever reason.
2) I'm deliberately *not* worrying about finding general info about
*volume* specification, because, as I said, the file-naming rules can
change from one volume to another. The purpose of the module is to
answer the question: what filenames can I use *here* (in a particular
volume/directory).
3) I'm not really sure what the best way of dealing with #6 is. My
current plan is simply to check whether there is a limit to how long
file extensions can be, and whether periods can appear in other parts
of the filename. There are probably other things I could/should
check, but these seem to me to be the most important.
4) My algorithm is probably going to assume that any pre-existing
files have completely legal filenames: this could potentially cause
problems on filesystems in which "special" files can have names that
aren't legal for normal files. (E.g. I'll obviously have to make a
special exception for the filenames "." and "..")
So... comments?
-jason
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list