diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-09-10 22:00:39 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-09-10 22:00:39 (GMT) |
commit | 697842f58cfa15e86e92fa1c2733d7d9908a340e (patch) | |
tree | 7f5045964d5946de3f348459fb485a2463eddb69 /Mac/Python | |
parent | b0e8e9b72fb6eb42ecd4d9ea9e88563d1ca4528a (diff) | |
download | cpython-697842f58cfa15e86e92fa1c2733d7d9908a340e.zip cpython-697842f58cfa15e86e92fa1c2733d7d9908a340e.tar.gz cpython-697842f58cfa15e86e92fa1c2733d7d9908a340e.tar.bz2 |
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
parameter for the return string (as unix pathnames are not limited
by the 255 char pstring limit).
Implemented the function for MachO-Python, where it returns unix pathnames.
Diffstat (limited to 'Mac/Python')
-rw-r--r-- | Mac/Python/macgetargv.c | 30 | ||||
-rw-r--r-- | Mac/Python/macgetpath.c | 9 |
2 files changed, 17 insertions, 22 deletions
diff --git a/Mac/Python/macgetargv.c b/Mac/Python/macgetargv.c index c5af0ec..8fdbad5 100644 --- a/Mac/Python/macgetargv.c +++ b/Mac/Python/macgetargv.c @@ -54,10 +54,16 @@ typedef unsigned long refcontype; #include "Python.h" #include "macglue.h" +#ifdef TARGET_API_MAC_OSX +#define PATHNAMELEN 1024 +#else +#define PATHNAMELEN 256 +#endif + static int arg_count; static char *arg_vector[256]; FSSpec PyMac_ApplicationFSSpec; -char PyMac_ApplicationPath[256]; +char PyMac_ApplicationPath[PATHNAMELEN]; /* Duplicate a string to the heap. We also export this since it isn't standard ** and others use it @@ -73,22 +79,6 @@ strdup(const char *src) } #endif -#if TARGET_API_MAC_OSX -OSErr -PyMac_GetFullPath(FSSpec *fss, char *path) -{ - FSRef fsr; - OSErr err; - - *path = '\0'; - err = FSpMakeFSRef(fss, &fsr); - if ( err ) return err; - err = (OSErr)FSRefMakePath(&fsr, path, 1024); - if ( err ) return err; - return 0; -} -#endif /* TARGET_API_MAC_OSX */ - #if !TARGET_API_MAC_OSX /* Initialize FSSpec and full name of current application */ @@ -109,7 +99,7 @@ PyMac_init_process_location(void) info.processAppSpec = &PyMac_ApplicationFSSpec; if ( err=GetProcessInformation(¤tPSN, &info)) return err; - if ( err=PyMac_GetFullPath(&PyMac_ApplicationFSSpec, PyMac_ApplicationPath) ) + if ( err=PyMac_GetFullPathname(&PyMac_ApplicationFSSpec, PyMac_ApplicationPath, PATHNAMELEN) ) return err; applocation_inited = 1; return 0; @@ -170,7 +160,7 @@ handle_open_doc(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype r DescType rttype; long i, ndocs, size; FSSpec fss; - char path[1024]; + char path[PATHNAMELEN]; got_one = 1; if ((err = AEGetParamDesc(theAppleEvent, @@ -185,7 +175,7 @@ handle_open_doc(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype r &keywd, &rttype, &fss, sizeof(fss), &size); if (err) break; - PyMac_GetFullPath(&fss, path); + PyMac_GetFullPathname(&fss, path, PATHNAMELEN); arg_vector[arg_count++] = strdup(path); } return err; diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c index 83117ed..e087023 100644 --- a/Mac/Python/macgetpath.c +++ b/Mac/Python/macgetpath.c @@ -38,6 +38,11 @@ PERFORMANCE OF THIS SOFTWARE. #include <unistd.h> #endif +#ifdef TARGET_API_MAC_OSX +#define PATHNAMELEN 1024 +#else +#define PATHNAMELEN 256 +#endif /* Return the initial python search path. This is called once from ** initsys() to initialize sys.path. @@ -244,7 +249,7 @@ char * PyMac_GetPythonDir() { static int diditbefore = 0; - static char name[256] = {':', '\0'}; + static char name[PATHNAMELEN] = {':', '\0'}; AliasHandle handle; FSSpec dirspec; Boolean modified = 0; @@ -285,7 +290,7 @@ PyMac_GetPythonDir() if ( prefrh != -1 ) CloseResFile(prefrh); UseResFile(oldrh); - if ( PyMac_GetFullPath(&dirspec, name) == 0 ) { + if ( PyMac_GetFullPathname(&dirspec, name, PATHNAMELEN) == 0 ) { strcat(name, ":"); } else { /* If all fails, we return the current directory */ |