#include "dpl/utils/path.h"
#include <dpl/utils/wrt_utility.h>
-#include <dpl/scoped_free.h>
#include <dpl/errno_string.h>
#include <dpl/file_input.h>
#include <dpl/file_output.h>
#include <dpl/copy.h>
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
#include <dpl/foreach.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <unistd.h>
#include <ftw.h>
#include <sys/time.h>
+#include <dpl/free_deleter.h>
+#include <memory>
namespace DPL {
if(src.empty()) ThrowMsg(EmptyPath, "Path cannot be empty");
if(src[0] != '/')
{
- DPL::ScopedFree<char> root(getcwd(NULL,0));
- Tokenize(std::string(root.Get()), "\\/", std::inserter(m_parts, m_parts.begin()), true);
+ std::unique_ptr<char[],free_deleter> root(getcwd(NULL,0));
+ Tokenize(std::string(root.get()), "\\/", std::inserter(m_parts, m_parts.begin()), true);
}
Tokenize(src, "\\/", std::inserter(m_parts, m_parts.end()), true);
}
{
flag = this->IsFile();
} Catch (Path::NotExists) {
- LogPedantic(*this << "is not a file.");
+ WrtLogD("%s is not a file.", Fullpath().c_str());
}
return flag;
}
{
flag = this->IsDir();
} Catch (Path::NotExists) {
- LogPedantic(*this << "is not a directory.");
+ WrtLogD("%s is not a directory.", Fullpath().c_str());
}
return flag;
}
return S_ISLNK(tmp.st_mode);
}
+std::size_t Path::LastWriteTime() const
+{
+ struct stat st;
+ memset(&st, 0, sizeof(struct stat));
+ if (-1 == stat(Fullpath().c_str(), &st)) {
+ ThrowMsg(NotExists, DPL::GetErrnoString());
+ }
+ return st.st_mtime;
+}
+
bool Path::operator==(const Path & other) const
{
return m_parts == other.m_parts;
bool Path::hasExtension(const std::string& extension) const
{
- LogPedantic("Looking for extension " << extension);
+ WrtLogD("Looking for extension %s", extension.c_str());
if(Extension() == extension)
{
}
Catch(DPL::FileInput::Exception::Base)
{
- LogError("File input error");
+ WrtLogE("File input error");
ReThrowMsg(DPL::CopyFailed, std::string("File input error") + from.Fullpath());
}
Catch(DPL::FileOutput::Exception::Base)
{
- LogError("File output error");
+ WrtLogE("File output error");
ReThrowMsg(DPL::CopyFailed, std::string("File output error") + to.Fullpath());
}
Catch(DPL::CopyFailed)
{
- LogError("File copy error");
+ WrtLogE("File copy error");
ReThrowMsg(DPL::CopyFailed, std::string("File copy error") + from.Fullpath());
}
}
Path CreateTempPath(const Path & basePath)
{
- LogDebug("Step: Creating temporary path");
+ WrtLogD("Step: Creating temporary path");
// Temporary path
Path tempPath = basePath;