Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't put directory path into ofstream filename




On Jan 25, 2005, at 2:47 AM, Big Pilot wrote:

I'm trying to open a file in a specific directory using ofstream:

ofstream myfile("/usr/bin/hello.txt");

but I keep ending up with a file named "/usr/bin/hello.txt" in the directory where the executable is located. I tried different combinations of backslashes, forward slashes and escape characters but none seemed to work. How do I create a file in a specific directory, preferably by just changing the path in the filename?

Are you using CodeWarrior and their MSL libraries? If so, you may want to consider switching to the BSD libraries.


If so, I imagine their stream code may likely rely on HFS style pathnames. In which case what you're trying to do will not work. There are APIs for converting between POSIX style (what you have above) and HFS style (which you can find to CW's MSL libraries). Start with CFURL.h -- CFURLCreateWithFileSystemPath() and CFURLCopyFileSystemPath() in particular.


Bryan

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Can't put directory path into ofstream filename (From: "Big Pilot" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.