ThinkC Locate the current System Folder

Relating to ThinkC Development

eric

Administrator
Staff member
Sep 2, 2021
1,052
1,738
113
MN
bluescsi.com
I'm trying find how to open the currently running System file. System Folders can be named anything - just needs to have a System in it.

Is there a Toolbox API to determine the currently running System? My retro usenet search didn't turn up much.
 

joevt

Tinkerer
Mar 5, 2023
99
40
18
Code:
SysEnvRec sysEnv;
OSErr err = SysEnvirons (1, &sysEnv);
sysVRefNum of SysEnvRec is a working directory ID, not a volume reference ID or a directory reference ID.

The currently running System file is always open. So you would get the file reference number (probably just kSystemResFile), and use something like PBGetFCBInfoSync to get more info if you want to know where it is.
 

ryandesign

New Tinkerer
May 11, 2024
10
7
3
www.ryandesign.com
If you're interested in the System file, the preceding is correct.

If you're looking for the System Folder, then in System 7 and later you should use FindFolder. Your development environment might include glue code that lets you use FindFolder even on systems older than 7; if not, you'll need to write your own alternative code for older systems.
 

joevt

Tinkerer
Mar 5, 2023
99
40
18
If you're interested in the System file, the preceding is correct.

If you're looking for the System Folder, then in System 7 and later you should use FindFolder. Your development environment might include glue code that lets you use FindFolder even on systems older than 7; if not, you'll need to write your own alternative code for older systems.

If the glue code doesn't exist, then you can check gestalt gestaltFindFolderAttr to see if FindFolder is available.

The glue code is mention in
https://bitsavers.org/pdf/apple/mac...2_Toolbox_Interfaces_and_Libraries_199107.pdf
That says FindFolder is in Interface.o but I haven't disassembled it to see what it does. Maybe it uses gestalt for you.