Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Filename having frontslash

Filename having frontslash
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2008
Status: Offline
Reply With Quote
Dec 18, 2008, 03:52 AM
 
Hi all,
I'm working on MAC carbon.
I want to create file having frontslash("/") in filename (ex: hello/world.pdf).
I used API fopen and open but these functions will consider the filename as path eventhough I escaped frontslash.
How can I create or open file containing frontslash(/) in its name.
Can any one provide code sniplet for that?

Thanks in advance.
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
Dec 18, 2008, 04:11 AM
 
/ and : are not generally permitted in Mac filenames for compability purposes. : is the file-directory separator on Classic Mac OS, and / is the same in UNIX and the Openstep OS X was derived from. If you import a file from the classic OS with a / in it, it will be displayed in the Finder with a / and with a : in the Terminal. If you import a file with a : from a UNIX system, it will look the same. Both will be stored with a / in the name on HFS+ and with a : on UFS.

Carbon is just trying to save you from yourself. Escaping has nothing to do with it - that is not a legal filename.
     
Fresh-Faced Recruit
Join Date: Dec 2008
Status: Offline
Reply With Quote
Dec 18, 2008, 04:33 AM
 
Thanks for your replay.

But I have 1 question how the applications preview in mac is allowing
     
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Dec 18, 2008, 08:53 AM
 
Interesting point, I didn't realize the terminal would still show you the filename with a colon in it while the finder displays the slash.

I just tested renaming a file and adding a colon in the name via terminal. Guess what, the file in the finder displayed it as a slash.

$ mv "test.pdf" "test:testing.pdf"

yielded a file with the name "test/testing.pdf" when viewed from the finder. This may help you determine how to provide a workaround if the naming is critical to include the slash (at least visually). I can't imagine why this would be necessary as going-forward the names showing a slash, while useful in OS9, simply don't make sense to use in today's OS X.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 18, 2008, 02:04 PM
 
On HFS+, internally, the character stored is a slash. Colons are illegal under HFS+. But the POSIX layer uses slashes as a path separator, so OS X translates between slashes and colons. So on most Macs, the Finder is actually showing you the correct name while the POSIX APIs are seeing a censored version.
(Last edited by Chuckit; Dec 18, 2008 at 11:11 PM. )
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Dec 18, 2008, 06:28 PM
 
Pretty crazy, I always thought HFS used colons because OS 9 path names had colons.

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 18, 2008, 11:07 PM
 
HFS+ does use colons as the path delimiter. But the colons you see on the command line (inside file names rather than dividing up folders) are actually slashes in the file system.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:51 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2