aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpdiff/skpdiff_util.cpp
diff options
context:
space:
mode:
authorGravatar zachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-02 15:54:30 +0000
committerGravatar zachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-02 15:54:30 +0000
commita479aa1366734f80360a00e3020f5b148cb3c060 (patch)
tree45f634109d0ed6d430f5fbbb80ce4a3b15aca797 /tools/skpdiff/skpdiff_util.cpp
parent89066e5cd50b81d3703b449bea242aac70833211 (diff)
fix skpdiff viewer bug when using relative paths
BUG=skia:1463 R=djsollen@google.com Review URL: https://codereview.chromium.org/21601002 git-svn-id: http://skia.googlecode.com/svn/trunk@10515 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/skpdiff/skpdiff_util.cpp')
-rw-r--r--tools/skpdiff/skpdiff_util.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/skpdiff/skpdiff_util.cpp b/tools/skpdiff/skpdiff_util.cpp
index 0047959b60..5b19c7311d 100644
--- a/tools/skpdiff/skpdiff_util.cpp
+++ b/tools/skpdiff/skpdiff_util.cpp
@@ -15,10 +15,15 @@
# include <glob.h>
#endif
+#if SK_BUILD_FOR_MAC
+# include <sys/syslimits.h> // PATH_MAX is here for Macs
+#endif
+
#if SK_BUILD_FOR_WIN32
# include <windows.h>
#endif
+#include <stdlib.h>
#include <time.h>
#include "SkOSFile.h"
#include "skpdiff_util.h"
@@ -181,3 +186,21 @@ bool glob_files(const char globPattern[], SkTArray<SkString>* entries) {
return false;
#endif
}
+
+SkString get_absolute_path(const SkString& path) {
+#if SK_BUILD_FOR_MAC || SK_BUILD_FOR_UNIX || SK_BUILD_FOR_ANDROID
+ SkString fullPath(PATH_MAX + 1);
+ if (realpath(path.c_str(), fullPath.writable_str()) == NULL) {
+ fullPath.reset();
+ }
+ return fullPath;
+#elif SK_BUILD_FOR_WIN32
+ SkString fullPath(MAX_PATH);
+ if (_fullpath(fullPath.writable_str(), path.c_str(), MAX_PATH) == NULL) {
+ fullPath.reset();
+ }
+ return fullPath;
+#else
+ return SkString();
+#endif
+}