if (!Utils::isAbsolutePath(localPath)) {
localPath = directory + "/" + localPath;
}
+ status = CommunicationProtocol::getInstance(SH).makeDirectory(
+ Utils::dirname(localPath), "", "");
+ if (status)
+ LOG("Directory creation failed. Status is: " << status);
status = _protocol.copyFile(remotePath, _hostname, _username,
localPath, "", "");
if (status)
return path[0] == '/';
}
+std::string Utils::dirname(const std::string & path)
+{
+#ifdef WIN32
+ const char separator = '\\';
+#else
+ const char separator = '/';
+#endif
+ std::size_t found = path.rfind(separator);
+ if(found != std::string::npos)
+ return path.substr(0, found+1);
+ else
+ return std::string(".");
+}
+
string Utils::createAndOpenTemporaryFile(const string & prefix, ofstream & outputStream)
{
if (outputStream.is_open())
*/
static bool isAbsolutePath(const std::string & path);
+ /**
+ * Returns the directory name of a path.
+ * "/a/b/file.txt" -> "/a/b"
+ * "a/file.txt" -> "a"
+ * "file.txt" -> "."
+ */
+ static std::string dirname(const std::string & path);
+
/**
* Create a temporary file and open an output stream to write into this file.
* The file is created with the pattern "<tmpdir>/libbatch-<prefix>-XXXXXX" where <tmpdir> is the