MCPcopy Create free account
hub / github.com/NetHack/NetHack / macopen

Function macopen

outdated/sys/mac/macfile.c:208–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208int
209macopen(const char *name, int flags, long fileType)
210{
211 short refNum;
212 short perm;
213 Str255 s;
214
215 C2P(name, s);
216 if (flags & O_CREAT) {
217 if (HCreate(theDirs.dataRefNum, theDirs.dataDirID, s, TEXT_CREATOR,
218 fileType) && (flags & O_EXCL)) {
219 return -1;
220 }
221#if 0 /* Fails during makedefs */
222 if (fileType == SAVE_TYPE) {
223 short resRef;
224 HCreateResFile(theDirs.dataRefNum, theDirs.dataDirID, s);
225 resRef = HOpenResFile(theDirs.dataRefNum, theDirs.dataDirID, s,
226 fsRdWrPerm);
227 if (resRef != -1) {
228 Handle name;
229 Str255 plnamep;
230
231 C2P(svp.plname, plnamep);
232 name = (Handle)NewString(plnamep);
233 if (name)
234 replace_resource(name, 'STR ', PLAYER_NAME_RES_ID,
235 "\pPlayer Name");
236
237 /* The application name resource. See IM VI, page 9-21. */
238 name = (Handle)GetString(APP_NAME_RES_ID);
239 if (name) {
240 DetachResource(name);
241 replace_resource(name, 'STR ', APP_NAME_RES_ID,
242 "\pApplication Name");
243 }
244
245 CloseResFile(resRef);
246 }
247 }
248#endif
249 }
250 /*
251 * Here, we should check for file type, maybe a SFdialog if
252 * we fail with default, etc. etc. Besides, we should use HOpen
253 * and permissions.
254 */
255 if ((flags & O_RDONLY) == O_RDONLY) {
256 perm = fsRdPerm;
257 }
258 if ((flags & O_WRONLY) == O_WRONLY) {
259 perm = fsWrPerm;
260 }
261 if ((flags & O_RDWR) == O_RDWR) {
262 perm = fsRdWrPerm;
263 }
264 if (HOpen(theDirs.dataRefNum, theDirs.dataDirID, s, perm, &refNum)) {
265 return OpenHandleFile(s, fileType);

Callers 5

open_levelfileFunction · 0.85
open_bonesfileFunction · 0.85
open_savefileFunction · 0.85
check_recordfileFunction · 0.85
maccreatFunction · 0.85

Calls 3

C2PFunction · 0.85
replace_resourceFunction · 0.85
OpenHandleFileFunction · 0.85

Tested by

no test coverage detected