Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jk2addict (4946)

  (email not shown publicly)
AOL IM: chrislaco (Add Buddy, Send Message)
Yahoo! ID: (Add User, Send Message)

Journal of jk2addict (4946)

Friday December 16, 2005
10:52 AM

Path::Class and translating paths

[ #28026 ]

This seems like an easy thing, but it's driving me bonkers. I've been working on a photo gallery app for Catalyst. One of the 'features' I discovered last night was that when I uploaded a file on Windows to the Unix server, file($file)->basename was giving me the whole file name, not just the base name for the windows files.

Given the power of Path::Class and File::Spec, I thought surely there was a better way. But I haven't found it yet.

There is foreign_file and as_foreign, even new_foreign. They all assume that I know the source file system. When uploading files over the web, I don't.

Now sure, I could do some hackery pokery to sniff the user-agent, or sniff the filename for / or \ or : or ::, but that's bad. That's why we have the magic that is Path::Class/File::Spec to begin with.

Maybe there should be a from_foreign() that does the sniffing magic and converts the output to the native fs on which it's running?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I do a lot of development across Windows and Unix boxes and have found URI::File to really help even out the path deliminator issues. However I am just learning Catalyst and am not so familiar with the classes you mentioned so I am not sure my advice will help. BTW, Something else you should watch out for is that on UNIX the current working directory is set to the path of the script, but on windows it's set to the location to wherever perl.exe is.
    Waiting on the Road to Eventually, I lost my Place On Line