Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Legacy Data Files on a Case-sensitive File-system

by jethro (Monsignor)
on Jan 21, 2010 at 00:27 UTC ( [id://818597]=note: print w/replies, xml ) Need Help??


in reply to Legacy Data Files on a Case-sensitive File-system

If you have to access just a few files, your method is probably already good enough.

If not, I can think of two methods to speed it up, both allow you to use all-lowercase filenames in your program:

1) Whenever your program starts, it checks whether there are still mixed-case filenames around (just check one file) and if yes, changes them all to lowercase (or uppercase if you prefer that). This means that when someone starts your program the first time with the downloaded data files, your program needs a little longer to start up. The next time all the files are already lowercase.

2) Generate a hash at startup that has the lowercased filename as key and the (real) mixed case filename as value. To access a file, look it up in the hash. The hash has to be generated whenever someone starts the program, but it shouldn't be a noticable delay because the program has to make just one sweep of the files on disk.

PS: Both algorithms need to do a sweep of the data files on disk. You might use File::Find to do this.

  • Comment on Re: Legacy Data Files on a Case-sensitive File-system

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://818597]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (1)
As of 2024-04-19 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found