static void testTransform(MprTestGroup *gp) { char *path; path = mprTransformPath("/", MPR_PATH_ABS); assert(mprIsPathAbs(path)); path = mprTransformPath("/", MPR_PATH_REL); assert(mprIsPathRel(path)); assert(path[0] == '.'); path = mprTransformPath("/", 0); assert(strcmp(path, "/") == 0); path = mprTransformPath("/", MPR_PATH_ABS); mprAssert(mprIsPathAbs(path)); #if BIT_WIN_LIKE || CYGWIN /* Test MapSeparators */ path = sclone("\\a\\b\\c\\d"); mprMapSeparators(path, '/'); assert(*path == '/'); assert(strchr(path, '\\') == 0); /* Test PortablePath */ path = sclone("\\a\\b\\c\\d"); path = mprGetPortablePath(path); mprAssert(*path == '/'); assert(strchr(path, '\\') == 0); assert(mprIsPathAbs(path)); #endif #if CYGWIN path = mprGetAbsPath("c:/a/b"); assert(smatch(path, "/cygdrive/c/a/b")); path = mprGetAbsPath("/a/b"); assert(smatch(path, "/a/b")); path = mprGetAbsPath("c:/cygwin/a/b"); assert(smatch(path, "/a/b")); path = mprGetWinPath("c:/a/b"); assert(smatch(path, "C:\\a\\b")); path = mprGetWinPath("/cygdrive/c/a/b"); assert(smatch(path, "C:\\a\\b")); #endif }
/* function get tmpdir(): Path */ static EjsPath *system_tmpdir(Ejs *ejs, EjsObj *unused, int argc, EjsObj **argv) { cchar *dir; #if WINCE dir = "/Temp"; #elif BIT_WIN_LIKE { MprFileSystem *fs; fs = mprLookupFileSystem("/"); dir = sclone(getenv("TEMP")); #if UNUSED mprMapSeparators(dir, defaultSep(fs)); #endif } #elif VXWORKS dir = "."; #else dir = "/tmp"; #endif return ejsCreatePathFromAsc(ejs, dir); }