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