Fix bug 73852

This commit is contained in:
Oleg Korshul
2025-05-28 23:27:08 +03:00
parent f9fb73fabc
commit f6ca336621
3 changed files with 54 additions and 6 deletions

View File

@ -611,8 +611,12 @@ public:
}
}
bool bIsCopied = false;
if (sLocalFilePath != sDestinationPath)
{
NSFile::CFileBinary::Copy(sLocalFilePath, sDestinationPath);
bIsCopied = true;
}
bool bIsTestFile = true;
if (!NSFile::CFileBinary::Exists(sDestinationPath))
@ -636,6 +640,9 @@ public:
return 0;
}
if (bIsCopied && (m_oInfo.m_nCurrentFileFormat == AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF || m_oInfo.m_nCurrentFileFormat == AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA))
NSSystem::CFileLocker::RemoveRestrictionFlags(sDestinationPath);
std::wstring sNameInfo = m_oInfo.m_sRecoveryDir + L"/asc_name.info";
if (NSFile::CFileBinary::Exists(sNameInfo))
NSFile::CFileBinary::Remove(sNameInfo);

View File

@ -186,6 +186,7 @@ namespace NSSystem
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
namespace NSSystem
{
@ -536,19 +537,19 @@ namespace NSSystem
CFileLocker* CFileLocker::Create(const std::wstring& file)
{
#ifdef _WIN32
#ifdef _WIN32
return new NSSystem::CFileLockerWin(file);
#endif
#endif
#ifdef _LINUX
#ifndef _MAC
#ifdef _LINUX
#ifndef _MAC
if (IsLocalFile(file))
return new NSSystem::CFileLockerFCNTL(file);
else
return new NSSystem::CFileLockerGIO(file);
#else
#else
return new NSSystem::CFileLockerEmpty(file);
#endif
#endif
#endif
// ERROR!!!
@ -572,4 +573,42 @@ namespace NSSystem
{
return CHandlesMonitor::Instance().IsExist(file);
}
bool CFileLocker::RemoveRestrictionFlags(const std::wstring& file)
{
#ifdef _LINUX
std::wstring fileA = U_TO_UTF8(file);
struct stat fileStat;
if (stat(fileA.c_str, &fileStat) != 0)
{
return false;
}
if (fileStat.st_mode & S_IWUSR)
return true;
if (chmod(filename, fileStat.st_mode | S_IWUSR) != 0)
{
return false;
}
return true;
#else
DWORD attrs = GetFileAttributesW(file.c_str());
if (attrs == INVALID_FILE_ATTRIBUTES)
{
return false;
}
if (0 == (attrs & FILE_ATTRIBUTE_READONLY))
return true;
if (!SetFileAttributesW(file.c_str(), attrs &= ~FILE_ATTRIBUTE_READONLY))
{
return false;
}
return true;
#endif
}
}

View File

@ -68,6 +68,8 @@ namespace NSSystem
static CFileLocker* Create(const std::wstring& file);
static bool IsHandled(const std::wstring& file);
static bool RemoveRestrictionFlags(const std::wstring& file);
};
}