Keep permissions of the saved files intact. (Backporting 04fe818b2239).

Apparently this code helps for qt5 only.
qt4 accepts setPermission, but does not seem to actually implement it.
This commit is contained in:
Pavel Sanda 2018-12-14 18:50:36 +01:00
parent 7bf1392c4d
commit 759769131a
3 changed files with 12 additions and 0 deletions

View File

@ -1431,6 +1431,9 @@ bool Buffer::save() const
FileName savefile(tempfile->name());
LYXERR(Debug::FILES, "Saving to " << savefile.absFileName());
if (!savefile.clonePermissions(fileName()))
LYXERR0("Failed to clone the permission from " << fileName().absFileName() << " to " << savefile.absFileName());
if (!writeFile(savefile))
return false;

View File

@ -278,6 +278,13 @@ bool FileName::changePermission(unsigned long int mode) const
return true;
}
bool FileName::clonePermissions(FileName const & source)
{
QFile fin(toqstr(source.absFileName()));
QFile f(toqstr(absFileName()));
return f.setPermissions(fin.permissions());
}
string FileName::toFilesystemEncoding() const
{

View File

@ -150,6 +150,8 @@ public:
/// support this.
/// \return true on success.
bool changePermission(unsigned long int mode) const;
// sets permission based on the file given as an argument
bool clonePermissions(FileName const & source);
/// remove pointed directory and all contents.
/// \return true on success.