X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffs%2Fredirectedpath.cpp;fp=source%2Ffs%2Fredirectedpath.cpp;h=6ca59cc59e6a1864dae203533a10e626a7c7af00;hb=d08f1d5d468beb303a4bd80f7e37169c464cf942;hp=0000000000000000000000000000000000000000;hpb=bcca7a40a6c59ee1effbaa1027a5364213434448;p=libs%2Fcore.git diff --git a/source/fs/redirectedpath.cpp b/source/fs/redirectedpath.cpp new file mode 100644 index 0000000..6ca59cc --- /dev/null +++ b/source/fs/redirectedpath.cpp @@ -0,0 +1,38 @@ +#include +#include "redirectedpath.h" +#include "stat.h" +#include "utils.h" + +using namespace std; + +namespace Msp { +namespace FS { + +RedirectedPath::RedirectedPath(const Path &p, const char *ext): + Path(p.str()+ext), + original(p) +{ } + +RedirectedPath::RedirectedPath(const Path &p, const string &ext): + Path(p.str()+ext), + original(p) +{ } + +RedirectedPath::RedirectedPath(const Path &p, const Path &r): + Path(r), + original(p) +{ } + +RedirectedPath::~RedirectedPath() +{ + if(exists(*this)) + { + if(uncaught_exception()) + unlink(*this); + else + rename(*this, original); + } +} + +} // namespace FS +} // namespace Msp