![]() |
|
Do you know where your variables are? | |
PerlMonks |
Windows LFN to 8.3 triviaby mkmcconn (Chaplain) |
on Mar 28, 2001 at 10:17 UTC ( #67760=perlquestion: print w/replies, xml ) | Need Help?? |
mkmcconn has asked for the wisdom of the Perl Monks concerning the following question: My work permits me to use Linux and FreeBSD most of the day, which I'm happy for just because it's fun. But, there are many things more easily done in Windows - like, working in Windows. So, this is not a Windows-bashing post, even though it may provide some amusement to Microsoft haters. I am embarrassed by what I'm about to show you, and proud of it at the same time. It's a workaround (in the bad sense) for one of the silliest day-to-day problems I face: Reassociate the "DOS" filename with the Long File Name, in Windows. It's a silly problem, but I want to tell you how I approached it and invite your better solutions. Some backround:
All the names of the files in this index correspond to the files in the zipped archive. However, the vendor's software, at some point between production and delivery, does not support Long File Names. Thus, the files in the archive display only an 8.3 name - the LFN has been disassociated from the file. The vendor has also shared this program with other agencies. Consequently, we see this problem with increasing frequency. The task is, reassociate the 8.3 filename with the LFN listed in the index, so that the index can be used and we can avoid renaming the files by hand. Here is part of the code that does that:
Yes, if you are still reading, what this sub does is, create a directory full of zero-byte files named according to the index file. The program then reads the filenames to get the Short Path supplied by the system. Another sub destroys these temporary files and the produced log ( OUT, when the work is completed. Why such a roundabout route? Well, as all you 12th level mages know, and as I've only recently found out: Microsoft has no less than three completely different LFN => 8.3 conversion algorithms for their three most common operating systems.
Under Windows NT:
Under Windows2000:
So, you see, the 8.3 name is created using a different algorithm, depending on the system.
So, a question/challenge to close, since I chose to post this in Seekers of Perl Wisdom:
I hope you find this at least amusing, or even educational, as I have.
Back to
Seekers of Perl Wisdom
|
|