else {      FSSpec		foundSpec; short		pathBufferSize; #if DEBUG char		*temp; #endif int		tempLen;   if ((strncmp(unixPath, "/usr/tmp", strlen("/usr/tmp")) == 0) || ((strncmp(unixPath, "/tmp", strlen("/tmp")) == 0))) { CInfoPBRec pb;  unixPath = PL_strchr(unixPath, PR_DIRECTORY_SEPARATOR); if (strncmp(unixPath, "/tmp", strlen("/tmp")) == 0) unixPath += 5; else unixPath += 9;  err = FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &foundSpec.vRefNum, &foundSpec.parID); if (err == noErr) { pb.dirInfo.ioCompletion = NULL; pb.dirInfo.ioNamePtr = foundSpec.name; pb.dirInfo.ioVRefNum = foundSpec.vRefNum; pb.dirInfo.ioFDirIndex = -1; pb.dirInfo.ioDrDirID = foundSpec.parID;  err = PBGetCatInfoSync(&pb); foundSpec.parID = pb.dirInfo.ioDrParID; } }  else if (!strncmp(unixPath, "/usr/local/netscape/", (tempLen = strlen("/usr/local/netscape/")))) {  unixPath += tempLen;  if (!strncmp(unixPath, "RequiredGuts/", (tempLen = strlen("RequiredGuts/")))) { unixPath += tempLen; err = FindGutsFolder(&foundSpec); } else if (!strncmp(unixPath, "bin/", (tempLen = strlen("bin/")))) { unixPath += tempLen; err = FindNetscapeFolder(&foundSpec); } else if (*unixPath == '\0') {  err = FindGutsFolder(&foundSpec); }  }  else {  err = CreateMacPathFromUnixPath(unixPath, macPath); goto Exit_ConvertUnixPathToMacPath; }     if (err == noErr) { Handle	hPathStr;  err = FSpGetFullPath(&foundSpec, &pathBufferSize, &hPathStr);  if (noErr == err) {    pathBufferSize++;  *macPath = (char*) malloc(sizeof(char) * pathBufferSize); (*macPath)[pathBufferSize - 1] = '\0'; BlockMoveData(*hPathStr, *macPath, pathBufferSize - 1);  DisposeHandle(hPathStr); } }  if (err == noErr) { UInt32	unixPathLeft; UInt32	macPathLen;  unixPathLeft =  strlen(unixPath); macPathLen = strlen(*macPath);    if (pathBufferSize - 1 < macPathLen + unixPathLeft) {  *macPath = realloc(*macPath, macPathLen + unixPathLeft + 1); err = (*macPath == NULL ? memFullErr : noErr); }  if (err == noErr) {        char*		dp; const char*	sp;  sp = unixPath; dp = *macPath + macPathLen;  for (;*sp != '\0'; sp++, dp++) { if (*sp == PR_DIRECTORY_SEPARATOR) {  if (sp > unixPath) {  if (sp[-1] == '\\') {  continue; } else { *dp = PR_PATH_SEPARATOR; } } else *dp = PR_PATH_SEPARATOR; } else {  *dp = *sp; } }  *dp = '\0'; } #if DEBUG    for (temp = *macPath + strlen(*macPath) - strlen(unixPath); *temp != '\0'; temp++) {  if (*temp == PR_DIRECTORY_SEPARATOR) { DebugStr("\pFound a slash"); *temp = PR_PATH_SEPARATOR; } } #endif } }   Exit_ConvertUnixPathToMacPath:  return err;
return (noErr);
PR_IMPLEMENT (OSErr)ConvertUnixPathToMacPath(const char *unixPath, char **macPath){			OSErr		err = noErr;			//	******** HACK ALERT ********	//	//	Java really wants long file names (>31 chars).  We truncate file names 	//	greater than 31 characters long.  Truncation is from the middle.	//	//	Convert UNIX style path names (with . and / separators) into a Macintosh	//	style path (with :).	//	// There are also a couple of special paths that need to be dealt with	// by translating them to the appropriate Mac special folders.  These include:	//	//			/usr/tmp/file  =>  {TempFolder}file	//	// The file conversions we need to do are as follows:	//	//			file			=>		file	//			dir/file		=>		:dir:file	//			./file			=>		file	//			../file			=>		::file	//			../dir/file		=>		::dir:file	//			/file			=>		::BootDrive:file	//			/dir/file		=>		::BootDrive:dir:file			if (!strcmp(unixPath, "."))	{		*macPath = malloc(sizeof(":"));		if (*macPath == NULL)			err = memFullErr;		(*macPath)[0] = ':';		(*macPath)[1] = '\0';	}	else		if (*unixPath != PR_DIRECTORY_SEPARATOR) {				// Not root relative, just convert it.		err = CreateMacPathFromUnixPath(unixPath, macPath);	}		else {		// Were root-relative.  This is either a special Unix directory, or a 		// full path (which well support on the Mac since they might be generated).		// This is not condoning the use of full-paths on the Macintosh for file 		// specification.				FSSpec		foundSpec;		short		pathBufferSize;#if DEBUG			char		*temp;#endif		int		tempLen;		// Are we dealing with the temp folder?		if ((strncmp(unixPath, "/usr/tmp", strlen("/usr/tmp")) == 0) || 			((strncmp(unixPath, "/tmp", strlen("/tmp")) == 0))) {		    CInfoPBRec pb;			unixPath = PL_strchr(unixPath, PR_DIRECTORY_SEPARATOR);			if (strncmp(unixPath, "/tmp", strlen("/tmp")) == 0) // skip past temp spec				unixPath += 5;				else				unixPath += 9;											err = FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder,	// Create if needed								&foundSpec.vRefNum, &foundSpec.parID);			if (err == noErr) {				pb.dirInfo.ioCompletion = NULL;				pb.dirInfo.ioNamePtr = foundSpec.name;				pb.dirInfo.ioVRefNum = foundSpec.vRefNum;				pb.dirInfo.ioFDirIndex = -1;				pb.dirInfo.ioDrDirID = foundSpec.parID;								err = PBGetCatInfoSync(&pb);				foundSpec.parID = pb.dirInfo.ioDrParID;			}		}				else if (!strncmp(unixPath, "/usr/local/netscape/", (tempLen = strlen("/usr/local/netscape/")))) {						unixPath += tempLen;						if (!strncmp(unixPath, "RequiredGuts/", (tempLen = strlen("RequiredGuts/"))))			{				unixPath += tempLen;				err = FindGutsFolder(&foundSpec);			}			else if (!strncmp(unixPath, "bin/", (tempLen = strlen("bin/"))))			{				unixPath += tempLen;				err = FindNetscapeFolder(&foundSpec);			}						else if (*unixPath == '\0')			{				// it's /usr/local/netscape				err = FindGutsFolder(&foundSpec);			}		}				else {			// This is a root relative directory, well just convert the whole thing.			err = CreateMacPathFromUnixPath(unixPath, macPath);			goto Exit_ConvertUnixPathToMacPath;		}					// Were dealing with a special folder		if (err == noErr)		{			Handle	hPathStr;			// Get the path to the root-relative directory			err = FSpGetFullPath(&foundSpec, &pathBufferSize, &hPathStr);		// NewHandle's hPathStr			 			if (noErr == err)			{				// convert handle to c-string				// add one for NULL termination				// pathBufferSize is now one greater than the length of the string				pathBufferSize++;									*macPath = (char*) malloc(sizeof(char) * pathBufferSize);				(*macPath)[pathBufferSize - 1] = '\0';				BlockMoveData(*hPathStr, *macPath, pathBufferSize - 1);							DisposeHandle(hPathStr);			}		}				if (err == noErr)		{			UInt32	unixPathLeft;			UInt32	macPathLen;			unixPathLeft =  strlen(unixPath);			macPathLen = strlen(*macPath);						// copy over the remaining file name, converting			if (pathBufferSize - 1 < macPathLen + unixPathLeft) 			{				// need to grow string				*macPath = realloc(*macPath, macPathLen + unixPathLeft + 1);				err = (*macPath == NULL ? memFullErr : noErr);			}						if (err == noErr)			{				// carefully remove the '/''s out of the unix path.  If we see an "escaped" /				// we will leave it in there, otherwise we take it out and replace it with a :				// we have to do this before we convert to a mac-path, so we can tell what is				// really a path separator and what is in the name of a file or directory				// Make sure that all of the /s are :s in the final pathname				// effectively we do a				// strcat(*macPath, unixPath); while replace all occurrences of / with : in unixPath				char*		dp;				const char*	sp;								sp = unixPath;				dp = *macPath + macPathLen;								for (;*sp != '\0'; sp++, dp++) 				{					if (*sp == PR_DIRECTORY_SEPARATOR)					{						// if we can look at the previous character						if (sp > unixPath)											{							// check to see if previous character is an escape							if (sp[-1] == '\\')							{								// leave it in, and cycle								continue;							}							else							{								*dp = PR_PATH_SEPARATOR;							}						}						else											*dp = PR_PATH_SEPARATOR;					}					else					{						// just copy;						*dp = *sp;					}				}								*dp = '\0';   // NULL terminate *macPath			}#if DEBUG				// we used to check here, now we check above, we leave this in			// the debug build to make sure we didn't screw up			// Make sure that all of the /s are :s in the final pathname			for (temp = *macPath + strlen(*macPath) - strlen(unixPath); *temp != '\0'; temp++) {				if (*temp == PR_DIRECTORY_SEPARATOR)				{					DebugStr("\pFound a slash");						*temp = PR_PATH_SEPARATOR;				}			}#endif		}	}		Exit_ConvertUnixPathToMacPath:	return err;}