X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/84e7f94cb078e98b31c5ba592e10d8311b24f65b..59c73be893dece9562e39ef7a2faa83b962c1d4e:/src/tiff/tif_apple.c?ds=sidebyside diff --git a/src/tiff/tif_apple.c b/src/tiff/tif_apple.c index 83f47bae97..1442df3c57 100644 --- a/src/tiff/tif_apple.c +++ b/src/tiff/tif_apple.c @@ -39,19 +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. */ -#ifdef __MACH__ - #include - #include - #include - #undef WCHAR_MAX - #include -#endif #include "tiffiop.h" -#include +#include #include #include +#include #if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec) #define CtoPstr c2pstr @@ -149,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. */ @@ -160,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; }