that a Freesound directory doesn't appear in /home/carl
without ever using Freesound.
git-svn-id: svn://localhost/ardour2/branches/3.0@11090
d708f5d6-7413-0410-9779-
e7cbd77b26cf
#include "sfdb_freesound_mootcher.h"\r
\r
#include "pbd/xml++.h"\r
#include "sfdb_freesound_mootcher.h"\r
\r
#include "pbd/xml++.h"\r
+#include "pbd/filesystem.h"\r
\r
#include <sys/stat.h>\r
#include <sys/types.h>\r
\r
#include <sys/stat.h>\r
#include <sys/types.h>\r
}\r
\r
//------------------------------------------------------------------------\r
}\r
\r
//------------------------------------------------------------------------\r
-const char* Mootcher::changeWorkingDir(const char *saveLocation)\r
+void Mootcher::changeWorkingDir(const char *saveLocation)\r
{\r
basePath = saveLocation;\r
#ifdef __WIN32__\r
{\r
basePath = saveLocation;\r
#ifdef __WIN32__\r
//\r
size_t pos2 = basePath.find_last_of("/");\r
if(basePath.length() != (pos2+1)) basePath += "/";\r
//\r
size_t pos2 = basePath.find_last_of("/");\r
if(basePath.length() != (pos2+1)) basePath += "/";\r
- // create Freesound directory and sound dir\r
- std::string sndLocation = basePath;\r
- mkdir(sndLocation.c_str(), 0777);\r
- sndLocation += "snd";\r
- mkdir(sndLocation.c_str(), 0777);\r
-\r
- return basePath.c_str();\r
+void Mootcher::ensureWorkingDir ()\r
+{\r
+ PBD::sys::path p = basePath;\r
+ p /= "snd";\r
+ if (!PBD::sys::is_directory (p)) {\r
+ PBD::sys::create_directories (p);\r
+ }\r
\r
//------------------------------------------------------------------------\r
size_t Mootcher::WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)\r
\r
//------------------------------------------------------------------------\r
size_t Mootcher::WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)\r
// std::cerr << "getSoundResourceFile: saving XML: " << xmlFileName << std::endl;\r
\r
// save the xml file to disk\r
// std::cerr << "getSoundResourceFile: saving XML: " << xmlFileName << std::endl;\r
\r
// save the xml file to disk\r
doc.write(xmlFileName.c_str());\r
\r
//store all the tags in the database\r
doc.write(xmlFileName.c_str());\r
\r
//store all the tags in the database\r
//------------------------------------------------------------------------\r
std::string Mootcher::getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, Gtk::ProgressBar *progress_bar)\r
{\r
//------------------------------------------------------------------------\r
std::string Mootcher::getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, Gtk::ProgressBar *progress_bar)\r
{\r
std::string audioFileName = basePath + "snd/" + ID + "-" + originalFileName;\r
\r
//check to see if audio file already exists\r
std::string audioFileName = basePath + "snd/" + ID + "-" + originalFileName;\r
\r
//check to see if audio file already exists\r
- const char* changeWorkingDir(const char *saveLocation);\r
+ void changeWorkingDir(const char *saveLocation);\r
+ void ensureWorkingDir();\r
\r
std::string doRequest(std::string uri, std::string params);\r
void setcUrlOptions();\r
\r
std::string doRequest(std::string uri, std::string params);\r
void setcUrlOptions();\r