diff options
Diffstat (limited to 'src/uri.cpp')
| -rw-r--r-- | src/uri.cpp | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/src/uri.cpp b/src/uri.cpp index a48aa8274..89f6f33e4 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -11,8 +11,6 @@ #include <glib.h> #include "uri.h" #include <string> -#include <cstring> -#include <iostream> // XXX #include <glibmm/ustring.h> #include <glibmm/miscutils.h> @@ -28,10 +26,6 @@ URI::URI(gchar const *preformed) throw(BadURIException) { if (!preformed) { throw MalformedURIException(); } - if( strncmp(preformed, "data:", 5)==0 ) { - parseDataUri( preformed + 5 ); - preformed = ""; // g_free? - } uri = xmlParseURI(preformed); if (!uri) { throw MalformedURIException(); @@ -141,38 +135,6 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) filename = tmp.toNativeFilename(); return filename; } - -/* - * Parse data:... uris so we can access their data transparently. - * otherwise data: is considered a malformed protocol like http: - * and two // as appended and the data is stored in the path of the uri. - */ -bool URI::parseDataUri(const char *uri) { - - int len = (strchr(uri, ',') - uri) * sizeof(char); - - const char *data; - std::string head; - if (len > 0) { - head = std::string(uri, len); - data = uri + len; - } else { - head = "text/plain"; - data = uri; - } - - //bool base64 = false; - std::cout << "Header: " << head << "\n"; - std::cout << "Data: " << data << "\n"; - /*while(uri < data) { - if (strncmp(uri,"base64",6) == 0) - base64 = true; - if (strncmp(uri,"image/", - data = strchr(uri, ';'); - }*/ - return true; -} - /* * 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 @@ -187,16 +149,12 @@ const std::string URI::getFullPath(std::string const base) const { if(!base.empty() && !path.empty() && path[0] != '/') { path = Glib::build_filename(base, path); } - // Normalise path, this only works if all parts of the path exist - char *output = realpath(path.c_str(), NULL); - if(output == NULL) { - path.clear(); - } else // Re-check the existance of the file (make damn sure) - if(! g_file_test(output, G_FILE_TEST_EXISTS) - || g_file_test(output, G_FILE_TEST_IS_DIR) ) { + // 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 std::string( output ); + return path; } |
