platform/macclassic.c
changeset 169 34829282ffe8
parent 166 ed10fe7cb16e
child 173 72a59de5e6e5
equal deleted inserted replaced
168:6b2a28327118 169:34829282ffe8
   163 } /* __PHYSFS_platformStricmp */
   163 } /* __PHYSFS_platformStricmp */
   164 
   164 
   165 
   165 
   166 static OSErr fnameToFSSpec(const char *fname, FSSpec *spec)
   166 static OSErr fnameToFSSpec(const char *fname, FSSpec *spec)
   167 {
   167 {
       
   168     OSErr err;
   168     Str255 str255;
   169     Str255 str255;
   169     int len = strlen(fname);
   170     int len = strlen(fname);
   170     if (len > 255)
   171     if (len > 255)
   171         return(bdNamErr);
   172         return(bdNamErr);
   172 
   173 
   173     /* !!! FIXME: What happens with relative pathnames? */
   174     /* !!! FIXME: What happens with relative pathnames? */
   174 
   175 
   175     str255[0] = strlen(fname);
   176     str255[0] = strlen(fname);
   176     memcpy(&str255[1], fname, str255[0]);
   177     memcpy(&str255[1], fname, str255[0]);
   177     return(FSMakeFSSpec(0, 0, str255, spec));
   178     err = FSMakeFSSpec(0, 0, str255, spec);
       
   179     return(err);
   178 } /* fnameToFSSpec */
   180 } /* fnameToFSSpec */
   179 
   181 
   180 
   182 
   181 int __PHYSFS_platformExists(const char *fname)
   183 int __PHYSFS_platformExists(const char *fname)
   182 {
   184 {
   193 
   195 
   194 int __PHYSFS_platformIsDirectory(const char *fname)
   196 int __PHYSFS_platformIsDirectory(const char *fname)
   195 {
   197 {
   196     FSSpec spec;
   198     FSSpec spec;
   197     CInfoPBRec infoPB;
   199     CInfoPBRec infoPB;
       
   200     OSErr err;
   198 
   201 
   199     BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, 0);
   202     BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, 0);
   200     memset(&infoPB, '\0', sizeof (CInfoPBRec));
   203     memset(&infoPB, '\0', sizeof (CInfoPBRec));
   201     infoPB.dirInfo.ioNamePtr = spec.name;     /* put name in here.       */
   204     infoPB.dirInfo.ioNamePtr = spec.name;     /* put name in here.       */
   202     infoPB.dirInfo.ioVRefNum = spec.vRefNum;  /* ID of file's volume.    */ 
   205     infoPB.dirInfo.ioVRefNum = spec.vRefNum;  /* ID of file's volume.    */ 
   203     infoPB.dirInfo.ioDrParID = spec.parID;    /* ID of bin's dir.        */
   206     infoPB.dirInfo.ioDrDirID = spec.parID;    /* ID of bin's dir.        */
   204     infoPB.dirInfo.ioFDirIndex = 0;           /* file (not parent) info. */
   207     infoPB.dirInfo.ioFDirIndex = 0;           /* file (not parent) info. */
   205     BAIL_IF_MACRO(PBGetCatInfoSync(&infoPB) != noErr, ERR_OS_ERROR, 0);
   208     err = PBGetCatInfoSync(&infoPB);
       
   209     BAIL_IF_MACRO((err != noErr) && (err != fnfErr), ERR_OS_ERROR, 0);
   206     return((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0);
   210     return((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0);
   207 } /* __PHYSFS_platformIsDirectory */
   211 } /* __PHYSFS_platformIsDirectory */
   208 
   212 
   209 
   213 
   210 char *__PHYSFS_platformCvtToDependent(const char *prepend,
   214 char *__PHYSFS_platformCvtToDependent(const char *prepend,
   261     {
   265     {
   262         memset(&infoPB, '\0', sizeof (CInfoPBRec));
   266         memset(&infoPB, '\0', sizeof (CInfoPBRec));
   263         str255[0] = 0;
   267         str255[0] = 0;
   264         infoPB.dirInfo.ioNamePtr = str255;        /* store name in here.     */
   268         infoPB.dirInfo.ioNamePtr = str255;        /* store name in here.     */
   265         infoPB.dirInfo.ioVRefNum = spec.vRefNum;  /* ID of file's volume.    */ 
   269         infoPB.dirInfo.ioVRefNum = spec.vRefNum;  /* ID of file's volume.    */ 
   266         infoPB.dirInfo.ioDrParID = spec.parID;    /* ID of bin's dir.        */
   270         infoPB.dirInfo.ioDrDirID = spec.parID;    /* ID of bin's dir.        */
   267         infoPB.dirInfo.ioFDirIndex = ++i;         /* file (not parent) info. */
   271         infoPB.dirInfo.ioFDirIndex = ++i;         /* file (not parent) info. */
   268         if (PBGetCatInfoSync(&infoPB) != noErr)
   272         if (PBGetCatInfoSync(&infoPB) != noErr)
   269             break;
   273             break;
   270 
   274 
   271         l = (LinkedStringList *) malloc(sizeof (LinkedStringList));
   275         l = (LinkedStringList *) malloc(sizeof (LinkedStringList));