Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / December 2005



Tip: Looking for answers? Try searching our database.

FSSpec and default stdio directory of a Carbon OS X app

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rhnlogic@yahoo.com - 20 Dec 2005 21:29 GMT
The default directory of a Carbon OS X application as used by stdio
seems to be at the level above that of the named app directory.
But MakeFSSpec() seems to assume that the default directory is
down in the ./appname/Contents/MacOS/ subdirectory, so can't
find the file just fopen'ed when called with a dirID of 0 or the
dirID of the calling process.

So does anyone have code for making an FSSpec out of file opened
by stdio when no path is specified in fopen() ?

I'm pasting two old programs together, and would like to set the
MacOS file type & creator after a unix stdio fopen/fclose for
cosmetic reasons.  Rewriting either old program (one Unix, one
converted Mac Classic) is unlikely worth the effort.

Thanks.
Signature

rhn A.T nicholson d.O.t C-o-M

David Phillip Oster - 21 Dec 2005 03:46 GMT
> The default directory of a Carbon OS X application as used by stdio
> seems to be at the level above that of the named app directory.
[quoted text clipped - 10 lines]
> cosmetic reasons.  Rewriting either old program (one Unix, one
> converted Mac Classic) is unlikely worth the effort.

It is a mistake to make any assumptions about what you get if you pass 0
for the vref and dirId in FSMakeFSSpec().

What C library are you using Apple's, Metrowerks, or another?

Most C libraries have calls to get your from a FILE* to an FSSpec. (Or,
since OS 9, an FSRef.)
Reinder Verlinde - 21 Dec 2005 17:57 GMT
> > The default directory of a Carbon OS X application as used by stdio
> > seems to be [...]
[quoted text clipped - 6 lines]
> > cosmetic reasons.  Rewriting either old program (one Unix, one
> > converted Mac Classic) is unlikely worth the effort.

> It is a mistake to make any assumptions about what you get if you pass 0
> for the vref and dirId in FSMakeFSSpec().
[quoted text clipped - 3 lines]
> Most C libraries have calls to get your from a FILE* to an FSSpec. (Or,
> since OS 9, an FSRef.)

Many older environments also have two global variables (_fcreator and
_ftype for Symantec C++) that allow one to specify creator and type of
files created using their C library. Usage would be:

   _fcreator = 'ttxt';
   _ftype    = 'TEXT';
   FILE * f = fopen( "Hello, world!", "w");
   ...

If such a change (and recompilation) is feasible for you, this might be
easier than messing around with paths.

Reinder
Allen Brunson - 21 Dec 2005 04:12 GMT
> The default directory of a Carbon OS X application as used by stdio
> seems to be [...]

do not assume any particular directory will be the default when your app is
started.  it can be different from one run to the next, depending on how the
app is launched.  this is probably the single-most-asked FAQ in the mac
programming groups.  you can google for it if you want details, personally i'm
too tired from the last fifty times this topic came up to go into it again.

what you want to do is determine what folder it is you're really looking for,
and construct a path that points there unequivocally.  say what it is you're
interested in in a follow-up question, and somebody can probably come up with
how you can locate said directory.
rhnlogic@yahoo.com - 21 Dec 2005 07:13 GMT
> > The default directory of a Carbon OS X application as used by stdio
> > seems to be [...]
>
> do not assume any particular directory will be the default when your app is
> started.  it can be different from one run to the next, depending on how the
> app is launched.

OK. I discovered that myself once I started launching my trial builds
from the Finder and command line instead of just the XCode debugger.

> this is probably the single-most-asked FAQ in the mac
> programming groups.  you can google for it if you want details, personally i'm
> too tired from the last fifty times this topic came up to go into it again.

What search terms do you recommend?  I tried googling on mixing
old FSSpec calls and stdio , but didn't find much about directory
defaults before I asked here.

> what you want to do is determine what folder it is you're really looking for,
> and construct a path that points there unequivocally.  say what it is you're
> interested in in a follow-up question, and somebody can probably come up with
> how you can locate said directory.

I know what to do when the use specifies a folder, either by full
posix path or Navigation services.  Now I'm trying to figure out some
simple thing to do when the user types in only a file name without a
directory, and not not save their data (and which works with both the
legacy Mac Classic or the unix stdio code base portions of the app).
chdir() & HSetVol to the users Documents directory?  Or ?

Thanks.
Signature

Ron
http://www.nicholson.com/rhn/basic

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.