[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

TortoiseMerge: Save as if readonly

From: ch3cooli <ch3cooli_at_yahoo.com.hk>
Date: Fri, 5 Apr 2013 05:42:50 -0700 (PDT)

If file is readonly, run "Save as" (ask new filename).
Especially for left view when edit mode is enabled, because there is no such checking.

--- a/src/TortoiseMerge/BaseView.cpp
+++ b/src/TortoiseMerge/BaseView.cpp
@@ -5343,11 +5343,16 @@ int CBaseView::SaveFile(int nFlags)
                                 break;
                         }
                 }
- if (!file.Save(m_pWorkingFile->GetFilename()))
+ CString filename = m_pWorkingFile->GetFilename();
+ if (m_pWorkingFile->IsReadonly())
+ if (!CCommonAppUtils::FileOpenSave(filename, NULL, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false, m_hWnd))
+ return -1;
+ if (!file.Save(filename))
                 {
                         ::MessageBox(m_hWnd, file.GetErrorString(), _T("TortoiseGitMerge"), MB_ICONERROR);
                         return -1;
                 }
+ m_pWorkingFile->SetFileName(filename);
                 m_pWorkingFile->StoreFileAttributes();
                 // m_dlgFilePatches.SetFileStatusAsPatched(sFilePath);
                 SetModified(FALSE);

--- a/src/TortoiseMerge/WorkingFile.h
+++ b/src/TortoiseMerge/WorkingFile.h
@@ -44,6 +44,7 @@ public:
         void SetOutOfUse();
 
         bool HasSourceFileChanged() const;
+ bool IsReadonly() const { return (m_attribs.dwFileAttributes != INVALID_FILE_ATTRIBUTES) && (m_attribs.dwFileAttributes & FILE_ATTRIBUTE_READONLY); }
         void StoreFileAttributes();
 
         // Move the details of the specified file to the current one, and then mark the specified file

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=3052616

To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2013-04-05 15:04:03 CEST

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.