#include "Mover.h"
+#include "support/FileName.h"
#include "support/filetools.h"
#include "support/lstrings.h"
-#include "support/lyxlib.h"
#include "support/Systemcall.h"
#include <fstream>
namespace lyx {
-bool Mover::copy(FileName const & from, FileName const & to,
- unsigned long int mode) const
+bool Mover::copy(FileName const & from, FileName const & to) const
{
- return do_copy(from, to, to.absFilename(), mode);
+ return do_copy(from, to, to.absFileName());
}
bool Mover::do_copy(FileName const & from, FileName const & to,
- string const &, unsigned long int mode) const
+ string const &) const
{
- return support::copy(from, to, mode);
+ return from.copyTo(to);
}
bool Mover::rename(FileName const & from,
FileName const & to) const
{
- return do_rename(from, to, to.absFilename());
+ return do_rename(from, to, to.absFileName());
}
bool Mover::do_rename(FileName const & from, FileName const & to,
string const &) const
{
- return rename(from, to);
+ return from.moveTo(to);
}
bool SpecialisedMover::do_copy(FileName const & from, FileName const & to,
- string const & latex, unsigned long int mode) const
+ string const & latex) const
{
if (command_.empty())
- return Mover::do_copy(from, to, latex, mode);
-
- if (mode != (unsigned long int)-1) {
- ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc);
- if (!ofs)
- return false;
- ofs.close();
- if (!chmod(to, mode))
- return false;
- }
+ return Mover::do_copy(from, to, latex);
string command = libScriptSearch(command_);
command = subst(command, "$$i", quoteName(from.toFilesystemEncoding()));
if (command_.empty())
return Mover::do_rename(from, to, latex);
- if (!do_copy(from, to, latex, (unsigned long int)-1))
+ if (!do_copy(from, to, latex))
return false;
return from.removeFile();
}