X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b47c832e5529dc6c632536b4665a005f0a85aec8..d10e22fe8ad283f37b1809349028ffc282e393ce:/src/tiff/tif_apple.c diff --git a/src/tiff/tif_apple.c b/src/tiff/tif_apple.c index bbebe27ca6..86cf215451 100644 --- a/src/tiff/tif_apple.c +++ b/src/tiff/tif_apple.c @@ -39,12 +39,17 @@ * Create below fills in a blank creator signature and sets the file type * to 'TIFF'. It is much better for the application to do this by Create'ing * the file first and TIFFOpen'ing it later. + * --------- + * This code has been "Carbonized", and may not work with older MacOS versions. + * If so, grab the tif_apple.c out of an older libtiff distribution, like + * 3.5.5 from www.libtiff.org. */ #include "tiffiop.h" -#include +#include #include #include +#include #if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec) #define CtoPstr c2pstr @@ -142,6 +147,13 @@ TIFFFdOpen(int fd, const char* name, const char* mode) return (tif); } +static void ourc2pstr( char* inString ) +{ + int sLen = strlen( inString ); + BlockMoveData( inString, &inString[1], sLen ); + inString[0] = sLen; +} + /* * Open a TIFF file for read/writing. */ @@ -153,32 +165,38 @@ TIFFOpen(const char* name, const char* mode) FInfo finfo; short fref; OSErr err; + FSSpec fSpec; strcpy((char*) pname, name); - CtoPstr((char*) pname); + ourc2pstr((char*) pname); + + err = FSMakeFSSpec( 0, 0, pname, &fSpec ); switch (_TIFFgetMode(mode, module)) { default: return ((TIFF*) 0); case O_RDWR | O_CREAT | O_TRUNC: - if (GetFInfo(pname, 0, &finfo) == noErr) - FSDelete(pname, 0); + if (FSpGetFInfo(&fSpec, &finfo) == noErr) + FSpDelete(&fSpec); /* fall through */ case O_RDWR | O_CREAT: - if ((err = GetFInfo(pname, 0, &finfo)) == fnfErr) { - if (Create(pname, 0, ' ', 'TIFF') != noErr) + if ((err = FSpGetFInfo(&fSpec, &finfo)) == fnfErr) { + if (FSpCreate(&fSpec, ' ', 'TIFF', smSystemScript) != noErr) goto badCreate; - if (FSOpen(pname, 0, &fref) != noErr) + if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) goto badOpen; } else if (err == noErr) { - if (FSOpen(pname, 0, &fref) != noErr) + if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) goto badOpen; } else goto badOpen; break; case O_RDONLY: + if (FSpOpenDF(&fSpec, fsRdPerm, &fref) != noErr) + goto badOpen; + break; case O_RDWR: - if (FSOpen(pname, 0, &fref) != noErr) + if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) goto badOpen; break; }