I have written a little CF app that parses my iTunes library.xml file,  
and builds structures of the track and playlist info.

When a user logs in, he sees a table of playlists and the info for the  
tracks in the selected playlist:

Song Title     Artist     Duration

Much as it appears in iTunes

when the user selects a tune, the trackID is sent to the program.

The program retrieves the location of the track by accessing the track  
structure:

    Application.Tracks[URL.TID]["Location"]

This returns a URL to the file in the format:

file://localhost/Users/test/Music/iTunes/iTunes%20Music/
Simon%20&%20Garfunkle/Unknown%20Album/Mrs.%20Robinson.mp3

The program URLDecodes this into a file path:

/Users/test/Music/iTunes/iTunes Music/Simon & Garfunkle/Unknown  
Album/Mrs. Robinson.mp3

Then the, program serves the file with:

     <!--- Abort if we can't find the file --->
     <cfif NOT FileExists((FilePath)) >
       <cfabort>
     </cfif>

<!--- this works for mp3 --->
<CFHEADER NAME="Content-Disposition"
  VALUE="attachment; filename=song.mp3">

<cfcontent type = "audio/mp3"
file=#FilePath#
deleteFile = "No">

All this works fine except when there is an ampersand (&) in the  
URL/file path.  Then, CF can't find the file to serve:

Now, OS X allows ampersands in file names and directory names.

When a song is iMported/read/dropped into iTunes, iTunes builds a  
directory structure based upon:

---Artist Name
------Album Name (or Unknown Album)
---------file name

in my example:

---Simon & Garfunkle
------Unknown Album
---------Mrs. Robinson.mp3

And CFFile  can't handle the ampersand in the "Simon & Garfunkle"  
directory.

The Mac Finder (File system GUI) has no problem with the ampersand.

But, the underlying FreeBSD Unix-based Darwin requires that the  
ampersand (and spaces) be escaped.

/Users/test/Music/iTunes/iTunes\ Music/Simon\ &\ Garfunkle/Unknown\  
Album/Mrs.\ Robinson.mp3

or the whole thing enclosed in quotes.

How do I get CFFile FileExists to handle a file path with an ampersand?

What characters should I look out for on windows-based iTunes?

TIA

Dick

"In times like these, it helps to recall that
there have always been times like these."
- Paul Harvey -
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to