[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] standardizePath unification
i've attached an attempt at unifying standardizePath for
linux/osx/(windows) to make it available on the commandline on osx.
any objections against committing this? this would make the
cocoaStandardizePath primitive superfluous.
another change is in sc_ResolveIfAlias to resolve symbolic links on osx.
<sk>
Index: source/lang/LangPrimSource/PyrUnixPrim.cpp
===================================================================
--- source/lang/LangPrimSource/PyrUnixPrim.cpp (revision 5674)
+++ source/lang/LangPrimSource/PyrUnixPrim.cpp (working copy)
@@ -298,28 +298,41 @@
return errNone;
}
-#ifndef SC_DARWIN
+#if SC_DARWIN
+# include <CoreFoundation/CoreFoundation.h>
+#endif // SC_DARWIN
-// should be unified for OSX and linux
int prString_StandardizePath(struct VMGlobals* g, int numArgsPushed);
int prString_StandardizePath(struct VMGlobals* g, int /* numArgsPushed */)
{
PyrSlot* arg = g->sp;
char ipath[PATH_MAX];
- char opath[PATH_MAX];
+ char opathbuf[PATH_MAX];
+ char* opath = opathbuf;
int err;
err = slotStrVal(arg, ipath, PATH_MAX);
if (err) return err;
- if (sc_StandardizePath(ipath, opath)) {
- PyrString* pyrString = newPyrString(g->gc, opath, 0, true);
- SetObject(arg, pyrString);
+ if (!sc_StandardizePath(ipath, opath)) {
+ opath = ipath;
}
+#if SC_DARWIN
+ CFStringRef cfstring =
+ CFStringCreateWithCString(NULL,
+ opath,
+ kCFStringEncodingUTF8);
+ err = !CFStringGetFileSystemRepresentation(cfstring, opath, PATH_MAX);
+ CFRelease(cfstring);
+ if (err) return errFailed;
+#endif // SC_DARWIN
+
+ PyrString* pyrString = newPyrString(g->gc, opath, 0, true);
+ SetObject(arg, pyrString);
+
return errNone;
}
-#endif // not SC_DARWIN
void initUnixPrimitives();
void initUnixPrimitives()
@@ -338,9 +351,7 @@
definePrimitive(base, index++, "_AscTime", prAscTime, 1, 0);
definePrimitive(base, index++, "_prStrFTime", prStrFTime, 2, 0);
definePrimitive(base, index++, "_TimeSeed", prTimeSeed, 1, 0);
-#ifndef SC_DARWIN
definePrimitive(base, index++, "_Cocoa_StandardizePath", prString_StandardizePath, 1, 0);
-#endif // not SC_DARWIN
}
Index: source/common/SC_DirUtils.cpp
===================================================================
--- source/common/SC_DirUtils.cpp (revision 5674)
+++ source/common/SC_DirUtils.cpp (working copy)
@@ -163,6 +163,9 @@
return;
}
}
+ if (!realpath(path, returnPath))
+ strcpy(returnPath, path);
+ return;
}
#elif defined(SC_LINUX)
if (!realpath(path, returnPath))