Fix bug 31191

This commit is contained in:
Oleg.Korshul
2024-09-12 21:33:39 +03:00
parent b757257882
commit f00283fad2
4 changed files with 40 additions and 1 deletions

View File

@ -501,6 +501,11 @@ namespace NSSystem
return true;
}
bool IsEmpty()
{
return m_pLocker->IsEmpty();
}
~CLocalFileLocker()
{
Unlock();

View File

@ -2881,6 +2881,16 @@ public:
bool bIsSaveAs = (sParams.find("saveas=true") != std::string::npos) ? true : false;
if (!bIsNeedSave)
{
if (m_pParent->m_pInternal->m_pLocalFileLocker &&
m_pParent->m_pInternal->m_pLocalFileLocker->IsEmpty() &&
!NSFile::CFileBinary::Exists(m_pParent->m_pInternal->m_oLocalInfo.m_oInfo.m_sFileSrc))
{
bIsNeedSave = true;
}
}
// нужно ли показывать диалог?
// 1) файл новый/восстановленный, т.е. некуда пока сохранять
// 2) saveAs

View File

@ -240,6 +240,18 @@ namespace NSSystem
virtual bool WriteFile(const void* pData, DWORD dwBytesToWrite, DWORD& dwSizeWrite)
{
if (!NSFile::CFileBinary::Exists(m_sFile))
{
Unlock();
std::wstring sDirectory = NSFile::GetDirectoryName(m_sFile);
NSDirectory::CreateDirectories(sDirectory);
NSFile::CFileBinary oFile;
oFile.CreateFile(m_sFile);
oFile.CloseFile();
Lock();
}
bool bResult = false;
if ( m_nDescriptor != -1 )
{
@ -248,6 +260,11 @@ namespace NSSystem
}
return bResult;
}
virtual bool IsEmpty()
{
return true;
}
};
class CFileLockerFCNTL : public CFileLockerEmpty
@ -546,6 +563,11 @@ namespace NSSystem
{
}
bool CFileLocker::IsEmpty()
{
return false;
}
bool CFileLocker::IsHandled(const std::wstring& file)
{
return CHandlesMonitor::Instance().IsExist(file);

View File

@ -34,7 +34,7 @@
#define FILELOCKER_H
#include <iostream>
#include "../../../../core/DesktopEditor/common/File.h"
#include "../../../../core/DesktopEditor/common/Directory.h"
#include "../../../../core/DesktopEditor/common/Types.h"
namespace NSSystem
@ -62,6 +62,8 @@ namespace NSSystem
virtual bool Truncate(DWORD dwPosition) = 0;
virtual bool WriteFile(const void* pData, DWORD dwBytesToWrite, DWORD& dwSizeWrite) = 0;
virtual bool IsEmpty();
static LockType IsLocked(const std::wstring& file);
static CFileLocker* Create(const std::wstring& file);