summaryrefslogtreecommitdiffstats
path: root/src/uri.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-01-27 22:03:02 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-01-27 22:03:02 +0000
commit5b962cdfdae8e7fee34211f7da4146eba5d763f9 (patch)
tree7ca839f8b4e6f2e67ed86915ba61641c0a10d714 /src/uri.cpp
parentupdate to trunk (diff)
parentProtect pdf and png exports from failure and output reasonalbe warnings. (diff)
downloadinkscape-5b962cdfdae8e7fee34211f7da4146eba5d763f9.tar.gz
inkscape-5b962cdfdae8e7fee34211f7da4146eba5d763f9.zip
update to trunk
(bzr r11950.1.237)
Diffstat (limited to 'src/uri.cpp')
-rw-r--r--src/uri.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/uri.cpp b/src/uri.cpp
index de6a454ec..89f6f33e4 100644
--- a/src/uri.cpp
+++ b/src/uri.cpp
@@ -10,7 +10,9 @@
#include <glib.h>
#include "uri.h"
+#include <string>
#include <glibmm/ustring.h>
+#include <glibmm/miscutils.h>
namespace Inkscape {
@@ -133,6 +135,28 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException)
filename = tmp.toNativeFilename();
return filename;
}
+/*
+ * Returns the absolute path to an existing file referenced in this URI,
+ * if the uri is data, the path is empty or the file doesn't exist, then
+ * an empty string is returned.
+ *
+ * Does not check if the returned path is the local document's path (local)
+ * and thus redundent. Caller is expected to check against the document's path.
+ */
+const std::string URI::getFullPath(std::string const base) const {
+ std::string path = std::string(_impl->getPath());
+ // Calculate the absolute path from an available base
+ if(!base.empty() && !path.empty() && path[0] != '/') {
+ path = Glib::build_filename(base, path);
+ }
+ // Check the existance of the file
+ if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS)
+ || g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) {
+ path.clear();
+ }
+ return path;
+}
+
/* TODO !!! proper error handling */
gchar *URI::toNativeFilename() const throw(BadURIException) {