macclassic.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * MacOS Classic support routines for PhysicsFS.
  3. *
  4. * Please see the file LICENSE in the source's root directory.
  5. *
  6. * This file written by Ryan C. Gordon.
  7. */
  8. #include <stdlib.h>
  9. #include <string.h>
  10. /*
  11. * Please note that I haven't tried this code with CarbonLib or under
  12. * MacOS X at all. The code in unix.c is known to work with Darwin,
  13. * and you may or may not be better off using that.
  14. */
  15. #ifdef __PHYSFS_CARBONIZED__
  16. #include <Carbon.h>
  17. #else
  18. #include <OSUtils.h>
  19. #include <Processes.h>
  20. #include <Files.h>
  21. #include <TextUtils.h>
  22. #include <Resources.h>
  23. #include <MacMemory.h>
  24. #include <Events.h>
  25. #include <DriverGestalt.h>
  26. #endif
  27. #define __PHYSICSFS_INTERNAL__
  28. #include "physfs_internal.h"
  29. const char *__PHYSFS_platformDirSeparator = ":";
  30. static struct ProcessInfoRec procInfo;
  31. static FSSpec procfsspec;
  32. int __PHYSFS_platformInit(void)
  33. {
  34. OSErr err;
  35. ProcessSerialNumber psn;
  36. BAIL_IF_MACRO(GetCurrentProcess(&psn) != noErr, ERR_OS_ERROR, 0);
  37. memset(&procInfo, '\0', sizeof (ProcessInfoRec));
  38. memset(&procfsspec, '\0', sizeof (FSSpec));
  39. procInfo.processInfoLength = sizeof (ProcessInfoRec);
  40. procInfo.processAppSpec = &procfsspec;
  41. err = GetProcessInformation(&psn, &procInfo);
  42. BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
  43. return(1); /* we're golden. */
  44. } /* __PHYSFS_platformInit */
  45. int __PHYSFS_platformDeinit(void)
  46. {
  47. return(1); /* always succeed. */
  48. } /* __PHYSFS_platformDeinit */
  49. /*
  50. * CD detection code is borrowed from Apple Technical Q&A DV18.
  51. * http://developer.apple.com/qa/dv/dv18.html
  52. */
  53. char **__PHYSFS_platformDetectAvailableCDs(void)
  54. {
  55. DriverGestaltParam pb;
  56. DrvQEl *dqp;
  57. OSErr status;
  58. char **retval = (char **) malloc(sizeof (char *));
  59. int cd_count = 1;
  60. BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
  61. *retval = NULL;
  62. pb.csCode = kDriverGestaltCode;
  63. pb.driverGestaltSelector = kdgDeviceType;
  64. dqp = (DrvQEl *) GetDrvQHdr()->qHead;
  65. while (dqp != NULL)
  66. {
  67. pb.ioCRefNum = dqp->dQRefNum;
  68. pb.ioVRefNum = dqp->dQDrive;
  69. status = PBStatusSync((ParmBlkPtr) &pb);
  70. if ((status == noErr) && (pb.driverGestaltResponse == kdgCDType))
  71. {
  72. Str63 volName;
  73. HParamBlockRec hpbr;
  74. memset(&hpbr, '\0', sizeof (HParamBlockRec));
  75. hpbr.volumeParam.ioNamePtr = volName;
  76. hpbr.volumeParam.ioVRefNum = dqp->dQDrive;
  77. hpbr.volumeParam.ioVolIndex = 0;
  78. if (PBHGetVInfoSync(&hpbr) == noErr)
  79. {
  80. char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
  81. if (tmp)
  82. {
  83. char *str = (char *) malloc(volName[0] + 1);
  84. retval = tmp;
  85. if (str != NULL)
  86. {
  87. memcpy(str, &volName[1], volName[0]);
  88. str[volName[0]] = '\0';
  89. retval[cd_count-1] = str;
  90. cd_count++;
  91. } /* if */
  92. } /* if */
  93. } /* if */
  94. } /* if */
  95. dqp = (DrvQEl *) dqp->qLink;
  96. } /* while */
  97. retval[cd_count - 1] = NULL;
  98. return(retval);
  99. } /* __PHYSFS_platformDetectAvailableCDs */
  100. char *__PHYSFS_platformCalcBaseDir(const char *argv0)
  101. {
  102. char *ptr;
  103. char *retval = NULL;
  104. UInt32 retLength = 0;
  105. CInfoPBRec infoPB;
  106. Str255 str255;
  107. FSSpec spec;
  108. /* Get the name of the binary's parent directory. */
  109. memcpy(&spec, &procfsspec, sizeof (FSSpec));
  110. memset(&infoPB, '\0', sizeof (CInfoPBRec));
  111. infoPB.dirInfo.ioNamePtr = str255; /* put name in here. */
  112. infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of bin's volume. */
  113. infoPB.dirInfo.ioDrParID = spec.parID; /* ID of bin's dir. */
  114. infoPB.dirInfo.ioFDirIndex = -1; /* get dir (not file) info. */
  115. /* walk the tree back to the root dir (volume), building path string... */
  116. do
  117. {
  118. /* check parent dir of what we last looked at... */
  119. infoPB.dirInfo.ioDrDirID = infoPB.dirInfo.ioDrParID;
  120. if (PBGetCatInfoSync(&infoPB) != noErr)
  121. {
  122. if (retval != NULL)
  123. free(retval);
  124. BAIL_MACRO(ERR_OS_ERROR, NULL);
  125. } /* if */
  126. /* allocate more space for the retval... */
  127. retLength += str255[0] + 1; /* + 1 for a ':' or null char... */
  128. ptr = (char *) malloc(retLength);
  129. if (ptr == NULL)
  130. {
  131. if (retval != NULL)
  132. free(retval);
  133. BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
  134. } /* if */
  135. /* prepend new dir to retval and cleanup... */
  136. memcpy(ptr, &str255[1], str255[0]);
  137. ptr[str255[0]] = '\0'; /* null terminate it. */
  138. if (retval != NULL)
  139. {
  140. strcat(ptr, ":");
  141. strcat(ptr, retval);
  142. free(retval);
  143. } /* if */
  144. retval = ptr;
  145. } while (infoPB.dirInfo.ioDrDirID != fsRtDirID);
  146. return(retval);
  147. } /* __PHYSFS_platformCalcBaseDir */
  148. char *__PHYSFS_platformGetUserName(void)
  149. {
  150. char *retval = NULL;
  151. StringHandle strHandle;
  152. short origResourceFile = CurResFile();
  153. /* use the System resource file. */
  154. UseResFile(0);
  155. /* apparently, -16096 specifies the username. */
  156. strHandle = GetString(-16096);
  157. UseResFile(origResourceFile);
  158. BAIL_IF_MACRO(strHandle == NULL, ERR_OS_ERROR, NULL);
  159. HLock((Handle) strHandle);
  160. retval = (char *) malloc((*strHandle)[0] + 1);
  161. if (retval == NULL)
  162. {
  163. HUnlock((Handle) strHandle);
  164. BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
  165. } /* if */
  166. memcpy(retval, &(*strHandle)[1], (*strHandle)[0]);
  167. retval[(*strHandle)[0]] = '\0'; /* null-terminate it. */
  168. HUnlock((Handle) strHandle);
  169. return(retval);
  170. } /* __PHYSFS_platformGetUserName */
  171. char *__PHYSFS_platformGetUserDir(void)
  172. {
  173. return(NULL); /* bah...use default behaviour, I guess. */
  174. } /* __PHYSFS_platformGetUserDir */
  175. PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
  176. {
  177. return(1); /* single threaded. */
  178. } /* __PHYSFS_platformGetThreadID */
  179. int __PHYSFS_platformStricmp(const char *x, const char *y)
  180. {
  181. extern int _stricmp(const char *, const char *);
  182. return(_stricmp(x, y)); /* (*shrug*) */
  183. } /* __PHYSFS_platformStricmp */
  184. static OSErr fnameToFSSpec(const char *fname, FSSpec *spec)
  185. {
  186. OSErr err;
  187. Str255 str255;
  188. int needColon = (strchr(fname, ':') == NULL);
  189. int len = strlen(fname) + ((needColon) ? 1 : 0);
  190. if (len > 255)
  191. return(bdNamErr);
  192. /* !!! FIXME: What happens with relative pathnames? */
  193. str255[0] = len;
  194. memcpy(&str255[1], fname, len);
  195. /* probably just a volume name, which seems to need a ':' at the end. */
  196. if (needColon)
  197. str255[len] = ':';
  198. err = FSMakeFSSpec(0, 0, str255, spec);
  199. return(err);
  200. } /* fnameToFSSpec */
  201. int __PHYSFS_platformExists(const char *fname)
  202. {
  203. FSSpec spec;
  204. return(fnameToFSSpec(fname, &spec) == noErr);
  205. } /* __PHYSFS_platformExists */
  206. int __PHYSFS_platformIsSymLink(const char *fname)
  207. {
  208. return(0); /* !!! FIXME: What happens if (fname) is an alias? */
  209. } /* __PHYSFS_platformIsSymlink */
  210. int __PHYSFS_platformIsDirectory(const char *fname)
  211. {
  212. FSSpec spec;
  213. CInfoPBRec infoPB;
  214. OSErr err;
  215. BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, 0);
  216. memset(&infoPB, '\0', sizeof (CInfoPBRec));
  217. infoPB.dirInfo.ioNamePtr = spec.name; /* put name in here. */
  218. infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of file's volume. */
  219. infoPB.dirInfo.ioDrDirID = spec.parID; /* ID of bin's dir. */
  220. infoPB.dirInfo.ioFDirIndex = 0; /* file (not parent) info. */
  221. err = PBGetCatInfoSync(&infoPB);
  222. BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
  223. return((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0);
  224. } /* __PHYSFS_platformIsDirectory */
  225. char *__PHYSFS_platformCvtToDependent(const char *prepend,
  226. const char *dirName,
  227. const char *append)
  228. {
  229. int len = ((prepend) ? strlen(prepend) : 0) +
  230. ((append) ? strlen(append) : 0) +
  231. strlen(dirName) + 1;
  232. const char *src;
  233. char *dst;
  234. char *retval = malloc(len);
  235. BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
  236. if (prepend != NULL)
  237. {
  238. strcpy(retval, prepend);
  239. dst = retval + strlen(retval);
  240. } /* if */
  241. else
  242. {
  243. *retval = '\0';
  244. dst = retval;
  245. } /* else */
  246. for (src = dirName; *src; src++, dst++)
  247. *dst = ((*src == '/') ? ':' : *src);
  248. *dst = '\0';
  249. return(retval);
  250. } /* __PHYSFS_platformCvtToDependent */
  251. void __PHYSFS_platformTimeslice(void)
  252. {
  253. SystemTask();
  254. } /* __PHYSFS_platformTimeslice */
  255. LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
  256. int omitSymLinks)
  257. {
  258. LinkedStringList *retval = NULL;
  259. LinkedStringList *l = NULL;
  260. LinkedStringList *prev = NULL;
  261. UInt16 i;
  262. UInt16 max;
  263. FSSpec spec;
  264. CInfoPBRec infoPB;
  265. Str255 str255;
  266. long dirID;
  267. BAIL_IF_MACRO(fnameToFSSpec(dirname, &spec) != noErr, ERR_OS_ERROR, 0);
  268. /* get the dir ID of what we want to enumerate... */
  269. memset(&infoPB, '\0', sizeof (CInfoPBRec));
  270. infoPB.dirInfo.ioNamePtr = spec.name; /* name of dir to enum. */
  271. infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of file's volume. */
  272. infoPB.dirInfo.ioDrDirID = spec.parID; /* ID of dir. */
  273. infoPB.dirInfo.ioFDirIndex = 0; /* file (not parent) info. */
  274. BAIL_IF_MACRO(PBGetCatInfoSync(&infoPB) != noErr, ERR_OS_ERROR, NULL);
  275. if ((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) == 0)
  276. BAIL_MACRO(ERR_NOT_A_DIR, NULL);
  277. dirID = infoPB.dirInfo.ioDrDirID;
  278. max = infoPB.dirInfo.ioDrNmFls;
  279. for (i = 1; i <= max; i++)
  280. {
  281. memset(&infoPB, '\0', sizeof (CInfoPBRec));
  282. str255[0] = 0;
  283. infoPB.dirInfo.ioNamePtr = str255; /* store name in here. */
  284. infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of dir's volume. */
  285. infoPB.dirInfo.ioDrDirID = dirID; /* ID of dir. */
  286. infoPB.dirInfo.ioFDirIndex = i; /* next file's info. */
  287. if (PBGetCatInfoSync(&infoPB) != noErr)
  288. continue; /* skip this file. Oh well. */
  289. l = (LinkedStringList *) malloc(sizeof (LinkedStringList));
  290. if (l == NULL)
  291. break;
  292. l->str = (char *) malloc(str255[0] + 1);
  293. if (l->str == NULL)
  294. {
  295. free(l);
  296. break;
  297. } /* if */
  298. memcpy(l->str, &str255[1], str255[0]);
  299. l->str[str255[0]] = '\0';
  300. if (retval == NULL)
  301. retval = l;
  302. else
  303. prev->next = l;
  304. prev = l;
  305. l->next = NULL;
  306. } /* for */
  307. return(retval);
  308. } /* __PHYSFS_platformEnumerateFiles */
  309. char *__PHYSFS_platformCurrentDir(void)
  310. {
  311. /*
  312. * I don't think MacOS has a concept of "current directory", beyond
  313. * what is grafted on by a given standard C library implementation,
  314. * so just return the base dir.
  315. * We don't use this for anything crucial at the moment anyhow.
  316. */
  317. return(__PHYSFS_platformCalcBaseDir(NULL));
  318. } /* __PHYSFS_platformCurrentDir */
  319. char *__PHYSFS_platformRealPath(const char *path)
  320. {
  321. /* !!! FIXME: This isn't nearly right. */
  322. char *retval = (char *) malloc(strlen(path) + 1);
  323. strcpy(retval, path);
  324. return(retval);
  325. } /* __PHYSFS_platformRealPath */
  326. int __PHYSFS_platformMkDir(const char *path)
  327. {
  328. SInt32 val = 0;
  329. FSSpec spec;
  330. OSErr err = fnameToFSSpec(path, &spec);
  331. BAIL_IF_MACRO(err == noErr, ERR_FILE_EXISTS, 0);
  332. BAIL_IF_MACRO(err != fnfErr, ERR_OS_ERROR, 0);
  333. err = DirCreate(spec.vRefNum, spec.parID, spec.name, &val);
  334. BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
  335. return(1);
  336. } /* __PHYSFS_platformMkDir */
  337. static SInt16 *macDoOpen(const char *fname, SInt8 perm, int createIfMissing)
  338. {
  339. int created = 0;
  340. SInt16 *retval = NULL;
  341. FSSpec spec;
  342. OSErr err = fnameToFSSpec(fname, &spec);
  343. BAIL_IF_MACRO((err != noErr) && (err != fnfErr), ERR_OS_ERROR, NULL);
  344. if (err == fnfErr)
  345. {
  346. BAIL_IF_MACRO(!createIfMissing, ERR_FILE_NOT_FOUND, NULL);
  347. err = HCreate(spec.vRefNum, spec.parID, spec.name,
  348. procInfo.processSignature, 'BINA');
  349. BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, NULL);
  350. created = 1;
  351. } /* if */
  352. retval = (SInt16 *) malloc(sizeof (SInt16));
  353. if (retval == NULL)
  354. {
  355. if (created)
  356. HDelete(spec.vRefNum, spec.parID, spec.name);
  357. BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
  358. } /* if */
  359. if (HOpenDF(spec.vRefNum, spec.parID, spec.name, perm, retval) != noErr)
  360. {
  361. free(retval);
  362. if (created)
  363. HDelete(spec.vRefNum, spec.parID, spec.name);
  364. BAIL_MACRO(ERR_OS_ERROR, NULL);
  365. } /* if */
  366. return(retval);
  367. } /* macDoOpen */
  368. void *__PHYSFS_platformOpenRead(const char *filename)
  369. {
  370. SInt16 *retval = macDoOpen(filename, fsRdPerm, 0);
  371. if (retval != NULL) /* got a file; seek to start. */
  372. {
  373. if (SetFPos(*retval, fsFromStart, 0) != noErr)
  374. {
  375. FSClose(*retval);
  376. BAIL_MACRO(ERR_OS_ERROR, NULL);
  377. } /* if */
  378. } /* if */
  379. return((void *) retval);
  380. } /* __PHYSFS_platformOpenRead */
  381. void *__PHYSFS_platformOpenWrite(const char *filename)
  382. {
  383. SInt16 *retval = macDoOpen(filename, fsRdWrPerm, 1);
  384. if (retval != NULL) /* got a file; truncate it. */
  385. {
  386. if ((SetEOF(*retval, 0) != noErr) ||
  387. (SetFPos(*retval, fsFromStart, 0) != noErr))
  388. {
  389. FSClose(*retval);
  390. BAIL_MACRO(ERR_OS_ERROR, NULL);
  391. } /* if */
  392. } /* if */
  393. return((void *) retval);
  394. } /* __PHYSFS_platformOpenWrite */
  395. void *__PHYSFS_platformOpenAppend(const char *filename)
  396. {
  397. SInt16 *retval = macDoOpen(filename, fsRdWrPerm, 1);
  398. if (retval != NULL) /* got a file; seek to end. */
  399. {
  400. if (SetFPos(*retval, fsFromLEOF, 0) != noErr)
  401. {
  402. FSClose(*retval);
  403. BAIL_MACRO(ERR_OS_ERROR, NULL);
  404. } /* if */
  405. } /* if */
  406. return(retval);
  407. } /* __PHYSFS_platformOpenAppend */
  408. PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
  409. PHYSFS_uint32 size, PHYSFS_uint32 count)
  410. {
  411. SInt16 ref = *((SInt16 *) opaque);
  412. SInt32 br;
  413. PHYSFS_uint32 i;
  414. for (i = 0; i < count; i++)
  415. {
  416. br = size;
  417. BAIL_IF_MACRO(FSRead(ref, &br, buffer) != noErr, ERR_OS_ERROR, i);
  418. BAIL_IF_MACRO(br != size, ERR_OS_ERROR, i);
  419. buffer = ((PHYSFS_uint8 *) buffer) + size;
  420. } /* for */
  421. return(count);
  422. } /* __PHYSFS_platformRead */
  423. PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
  424. PHYSFS_uint32 size, PHYSFS_uint32 count)
  425. {
  426. SInt16 ref = *((SInt16 *) opaque);
  427. SInt32 bw;
  428. PHYSFS_uint32 i;
  429. for (i = 0; i < count; i++)
  430. {
  431. bw = size;
  432. BAIL_IF_MACRO(FSWrite(ref, &bw, buffer) != noErr, ERR_OS_ERROR, i);
  433. BAIL_IF_MACRO(bw != size, ERR_OS_ERROR, i);
  434. buffer = ((PHYSFS_uint8 *) buffer) + size;
  435. } /* for */
  436. return(count);
  437. } /* __PHYSFS_platformWrite */
  438. int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos)
  439. {
  440. SInt16 ref = *((SInt16 *) opaque);
  441. OSErr err = SetFPos(ref, fsFromStart, (SInt32) pos);
  442. BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
  443. return(1);
  444. } /* __PHYSFS_platformSeek */
  445. PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
  446. {
  447. SInt16 ref = *((SInt16 *) opaque);
  448. SInt32 curPos;
  449. BAIL_IF_MACRO(GetFPos(ref, &curPos) != noErr, ERR_OS_ERROR, -1);
  450. return((PHYSFS_sint64) curPos);
  451. } /* __PHYSFS_platformTell */
  452. PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
  453. {
  454. SInt16 ref = *((SInt16 *) opaque);
  455. SInt32 eofPos;
  456. BAIL_IF_MACRO(GetEOF(ref, &eofPos) != noErr, ERR_OS_ERROR, -1);
  457. return((PHYSFS_sint64) eofPos);
  458. } /* __PHYSFS_platformFileLength */
  459. int __PHYSFS_platformEOF(void *opaque)
  460. {
  461. SInt16 ref = *((SInt16 *) opaque);
  462. SInt32 eofPos, curPos;
  463. BAIL_IF_MACRO(GetEOF(ref, &eofPos) != noErr, ERR_OS_ERROR, 1);
  464. BAIL_IF_MACRO(GetFPos(ref, &curPos) != noErr, ERR_OS_ERROR, 1);
  465. return(curPos >= eofPos);
  466. } /* __PHYSFS_platformEOF */
  467. int __PHYSFS_platformFlush(void *opaque)
  468. {
  469. SInt16 ref = *((SInt16 *) opaque);
  470. ParamBlockRec pb;
  471. memset(&pb, '\0', sizeof (ParamBlockRec));
  472. pb.ioParam.ioRefNum = ref;
  473. BAIL_IF_MACRO(PBFlushFileSync(&pb) != noErr, ERR_OS_ERROR, 0);
  474. return(1);
  475. } /* __PHYSFS_platformFlush */
  476. int __PHYSFS_platformClose(void *opaque)
  477. {
  478. SInt16 ref = *((SInt16 *) opaque);
  479. SInt16 vRefNum;
  480. HParamBlockRec hpbr;
  481. Str63 volName;
  482. BAIL_IF_MACRO(GetVRefNum (ref, &vRefNum) != noErr, ERR_OS_ERROR, 0);
  483. memset(&hpbr, '\0', sizeof (HParamBlockRec));
  484. hpbr.volumeParam.ioNamePtr = volName;
  485. hpbr.volumeParam.ioVRefNum = vRefNum;
  486. hpbr.volumeParam.ioVolIndex = 0;
  487. BAIL_IF_MACRO(PBHGetVInfoSync(&hpbr) != noErr, ERR_OS_ERROR, 0);
  488. BAIL_IF_MACRO(FSClose(ref) != noErr, ERR_OS_ERROR, 0);
  489. free(opaque);
  490. FlushVol(volName, vRefNum);
  491. return(1);
  492. } /* __PHYSFS_platformClose */
  493. int __PHYSFS_platformDelete(const char *path)
  494. {
  495. FSSpec spec;
  496. OSErr err;
  497. BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, ERR_OS_ERROR, 0);
  498. err = HDelete(spec.vRefNum, spec.parID, spec.name);
  499. BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
  500. return(1);
  501. } /* __PHYSFS_platformDelete */
  502. void *__PHYSFS_platformCreateMutex(void)
  503. {
  504. return((void *) 0x0001); /* no mutexes on MacOS Classic. */
  505. } /* __PHYSFS_platformCreateMutex */
  506. void __PHYSFS_platformDestroyMutex(void *mutex)
  507. {
  508. /* no mutexes on MacOS Classic. */
  509. } /* __PHYSFS_platformDestroyMutex */
  510. int __PHYSFS_platformGrabMutex(void *mutex)
  511. {
  512. return(1); /* no mutexes on MacOS Classic. */
  513. } /* __PHYSFS_platformGrabMutex */
  514. void __PHYSFS_platformReleaseMutex(void *mutex)
  515. {
  516. /* no mutexes on MacOS Classic. */
  517. } /* __PHYSFS_platformReleaseMutex */
  518. /* end of macclassic.c ... */