static String getExecutablePath() { CString executablePath = getCurrentExecutablePath(); if (!executablePath.isNull()) return directoryName(filenameToString(executablePath.data())); return String(); }
CString topLevelPath() { if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL")) return topLevelDirectory; // If the environment variable wasn't provided then assume we were built into // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build // directory is non-standard, but we can't do much more about this. GUniquePtr<char> parentPath(g_path_get_dirname(getCurrentExecutablePath().data())); GUniquePtr<char> layoutTestsPath(g_build_filename(parentPath.get(), "..", "..", "..", nullptr)); GUniquePtr<char> absoluteTopLevelPath(realpath(layoutTestsPath.get(), 0)); return absoluteTopLevelPath.get(); }
CString applicationDirectoryPath() { CString path = getCurrentExecutablePath(); if (!path.isNull()) return path; // If the above fails, check the PATH env variable. GUniquePtr<char> currentExePath(g_find_program_in_path(g_get_prgname())); if (!currentExePath.get()) return CString(); GUniquePtr<char> dirname(g_path_get_dirname(currentExePath.get())); return dirname.get(); }