Don't ask to ask, just ask | |
PerlMonks |
Validate windows filenames.by zzspectrez (Hermit) |
on Jul 14, 2005 at 06:47 UTC ( [id://474773]=perlquestion: print w/replies, xml ) | Need Help?? |
zzspectrez has asked for the wisdom of the Perl Monks concerning the following question: How do you validate filenames?I got bit in the butt.So here is my sob story. I have some old perl code that moves mp3 files and renames them based on the mp3 tag info. Well, I noticed the other day that a few songs had silenty disapeared during the move. The culprit was failure to validate the filenames. If an invalid character was in the destination filename, the file was moved into oblivion with no error. oooopps... So I did a quick search for some module that would validate filenames and could find nothing but this module VMS::FileUtils::SafeName that does not quite apply :) ... So of course I wrote some quick code to do the job.. But was wondering how everyone else is handling this situation. I was suprised to not find a relevant module on CPAN but maybee I am just search impaired this evening. Would also appreciate code review, since I suck with regexes! :)
To clear up any confusion about the purpose of this post. I'm not looking for solutions to the file copy/moving. I am looking for some discusion on handling filename validation/sanitizing. My Questions are: (1) Do fellow perlmonks routinely validate filenames? If so, how do you do it? (2) Any inherit problems with how my routines deal with validating/sanitizing windows filenames?? zzSPECTREz
Back to
Seekers of Perl Wisdom
|
|