diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-21 15:16:52 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-21 15:16:52 (GMT) |
commit | bd45c688b3d3aad5d62b85457ce943eaadf989ae (patch) | |
tree | 831d54da85c85f3e998be70241f8ffc3fed7f924 /src/uscxml/URL.cpp | |
parent | a52fb3364968e31a1a15c85ac45b68d9f531687b (diff) | |
download | uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.zip uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.tar.gz uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.tar.bz2 |
Added WebStorage object to document
Some refinements to DotWriter
Diffstat (limited to 'src/uscxml/URL.cpp')
-rw-r--r-- | src/uscxml/URL.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp index a58818a..4d60999 100644 --- a/src/uscxml/URL.cpp +++ b/src/uscxml/URL.cpp @@ -14,6 +14,8 @@ #define getcwd _getcwd #else #include <unistd.h> +#include <sys/types.h> +#include <pwd.h> #endif #include <cstdlib> // mkstemp @@ -49,6 +51,42 @@ std::string URL::tmpDir() { return tmpl; } +#if (!defined APPLE && !defined IOS) +std::string URL::getResourceDir() { +#ifdef _WIN32 + TCHAR szPath[MAX_PATH]; + if (SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szPath)) { + return szPath; + } else { + return getenv("APPDATA"); + } +#else + struct passwd* pw = getpwuid(getuid()); + std::string homedir(pw->pw_dir); + struct stat dirStat; + int err = 0; + + err = stat(std::string(homedir + PATH_SEPERATOR + ".config").c_str(), &dirStat); + if (err == ENOENT) { + err = mkdir(std::string(homedir + PATH_SEPERATOR + ".config").c_str(), S_IWUSR | S_IRUSR | S_IROTH); + } + + err = stat(std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml").c_str(), &dirStat); + if (err != 0) { + std::cout << std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml") << std::endl; + err = mkdir(std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml").c_str(), + S_IWUSR | S_IRUSR | S_IROTH | S_IRGRP | S_IXUSR | S_IXOTH | S_IXGRP); + } + + err = stat(std::string(homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml").c_str(), &dirStat); + if (err == 0) { + return homedir + PATH_SEPERATOR + ".config" + PATH_SEPERATOR + "uscxml"; + } + return ""; +#endif +} +#endif + URLImpl::URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false), _hasFailed(false) { std::stringstream ss(_uri.path()); std::string item; @@ -461,6 +499,11 @@ void URLFetcher::fetchURL(URL& url) { (curlError = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, false)) == CURLE_OK || LOG(ERROR) << "Cannot forfeit peer verification: " << curl_easy_strerror(curlError); + (curlError = curl_easy_setopt(handle, CURLOPT_USERAGENT, "curl/7.31.0")) == CURLE_OK || + LOG(ERROR) << "Cannot set our user agent string: " << curl_easy_strerror(curlError); + + (curlError = curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, true)) == CURLE_OK || + LOG(ERROR) << "Cannot enable follow redirects: " << curl_easy_strerror(curlError); if (boost::iequals(url._impl->_requestType, "post")) { |