int cd (char *command) { int retValue = 0; #if 0 if ( queryString("New directory: ", currentDir, PATH_MAX) != NULL && #ifdef ALWAYSEXPAND /* Always expand (like the shell). */ chdir(tildeExpand(currentDir)) == -1 #else /* Expand only if it doesn't exist in current dir. */ chdir(currentDir) == -1 && (errno != ENOENT || chdir(tildeExpand(currentDir)) == -1) #endif ) { perror(currentDir); retValue = -1; } getwd(currentDir); #endif return retValue; }
static void py2app_setPythonPath(void) { CFMutableArrayRef paths; CFURLRef resDir; CFStringRef resPath; CFArrayRef resPackages; CFDictionaryRef options; paths = py2app_CFArrayCreateMutable(NULL, 0, py2app_kCFTypeArrayCallBacks); resDir = py2app_CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); resPath = pathFromURL(resDir); py2app_CFArrayAppendValue(paths, resPath); py2app_CFRelease(resPath); resPackages = py2app_getKey("PyResourcePackages"); if (resPackages) { int i; int cnt = py2app_CFArrayGetCount(resPackages); for (i = 0; i < cnt; i++) { resPath = tildeExpand(py2app_CFArrayGetValueAtIndex(resPackages, i)); if (py2app_CFStringGetLength(resPath)) { if (py2app_CFStringGetCharacterAtIndex(resPath, 0) != '/') { CFURLRef absURL = py2app_CFURLCreateWithString( NULL, resPath, resDir); py2app_CFRelease(resPath); resPath = pathFromURL(absURL); py2app_CFRelease(absURL); } py2app_CFArrayAppendValue(paths, resPath); } py2app_CFRelease(resPath); } } py2app_CFRelease(resDir); options = py2app_getKey("PyOptions"); if (options) { CFBooleanRef use_pythonpath; CFNumberRef optimize; use_pythonpath = py2app_CFDictionaryGetValue( options, py2app_CFSTR("use_pythonpath")); if (use_pythonpath && py2app_CFBooleanGetValue(use_pythonpath)) { char *ppath = getenv("PYTHONPATH"); if (ppath) { CFArrayRef oldPath; oldPath = py2app_CFStringCreateArrayBySeparatingStrings( NULL, py2app_CFSTR(ppath), py2app_CFSTR(":")); if (oldPath) { CFRange rng; rng.location = 0; rng.length = py2app_CFArrayGetCount(oldPath); py2app_CFArrayAppendArray(paths, oldPath, rng); py2app_CFRelease(oldPath); } } } optimize = py2app_CFDictionaryGetValue( options, py2app_CFSTR("optimize")); if (optimize) { int v = 0; char buf[32]; py2app_CFNumberGetValue(optimize, kCFNumberIntType, &v); snprintf(buf, 31, "%d", v); setenv("PYTHONOPTIMIZE", buf, 1); } } if (py2app_CFArrayGetCount(paths)) { resPath = py2app_CFStringCreateByCombiningStrings(NULL, paths, py2app_CFSTR(":")); setcfenv("PYTHONPATH", resPath); py2app_CFRelease(resPath); } else { if (getenv("PYTHONPATH") != NULL) { unsetenv("PYTHONPATH"); } } py2app_CFRelease(paths); }