OSDN Git Service

PATCH: [ 765463 ] Simplify temp path handling a little
authorKimmo Varis <kimmov@gmail.com>
Fri, 4 Jul 2003 11:31:13 +0000 (11:31 +0000)
committerKimmo Varis <kimmov@gmail.com>
Fri, 4 Jul 2003 11:31:13 +0000 (11:31 +0000)
Src/MergeDoc.cpp
Src/MergeDoc.h
Src/readme.txt

index 990fdbb..b937c71 100644 (file)
@@ -1100,6 +1100,11 @@ void CMergeDoc::CDiffTextBuffer::ReadLineFromBuffer(TCHAR *lpLineBegin, DWORD dw
        InsertLine(lpLineBegin, dwLineLen);
 }
 
+void CMergeDoc::CDiffTextBuffer::SetTempPath(CString path)
+{
+       m_strTempPath = path;
+}
+
 BOOL CMergeDoc::CDiffTextBuffer::LoadFromFile(LPCTSTR pszFileName,
                int nCrlfStyle /*= CRLF_STYLE_AUTOMATIC*/)
 {
@@ -1224,30 +1229,10 @@ BOOL CMergeDoc::CDiffTextBuffer::SaveToFile (LPCTSTR pszFileName,
        UINT nBufSize = GetTextWithoutEmptys(0, 0, nLineCount - 1,
                nLastLength, text, m_bIsLeft, nCrlfStyle);
        
-       if (pszFileName)
-       {
-               // Temp files are in temp dir...
-               if (bTempFile)
-               {
-                       _tsplitpath(pszFileName, drive, dir, NULL, NULL);
-                       _tcscpy(szTempFileDir, drive);
-                       _tcscat(szTempFileDir, dir);
-               }
-               else
-               {
-                       if (!GetTempPath(_MAX_PATH, szTempFileDir))
-                       {
-                               // No temp dir, ugh! use document's dir then
-                               _tsplitpath(pszFileName, drive, dir, NULL, NULL);
-                               _tcscpy(szTempFileDir, drive);
-                               _tcscat(szTempFileDir, dir);
-                       }
-               }
-       }
-       else
+       if (!pszFileName)
                return FALSE;   // No filename, cannot save...
 
-       if (!::GetTempFileName(szTempFileDir, _T("MRG"), 0, szTempFileName))
+       if (!::GetTempFileName(m_strTempPath, _T("MRG"), 0, szTempFileName))
                return FALSE;  //Nothing to do if even tempfile name fails
 
        // Init filedata struct and open file as memory mapped 
@@ -1332,6 +1317,11 @@ BOOL CMergeDoc::InitTempFiles(const CString& srcPathL, const CString& strPathR)
        {
                return FALSE;
        }
+
+       // Set temp paths for buffers
+       m_ltBuf.SetTempPath(strTempPath);
+       m_rtBuf.SetTempPath(strTempPath);
+
        if (m_strTempLeftFile.IsEmpty())
        {
                TCHAR name[MAX_PATH];
index b7d6d73..d009655 100644 (file)
@@ -80,10 +80,12 @@ private :
         CMergeDoc * m_pOwnerDoc;
                BOOL m_bIsLeft;
                BOOL FlagIsSet(UINT line, DWORD flag);
+               CString m_strTempPath;
 
                int DetermineCRLFStyle(LPVOID lpBuf, DWORD dwLength);
                void ReadLineFromBuffer(TCHAR *lpLineBegin, DWORD dwLineLen = 0);
 public :
+               void SetTempPath(CString path);
                bool curUndoGroup();
                void ReplaceLine(int nLine, const CString& strText);
                void ReplaceFullLine(int nLine, const CString& strText);
index 4e55f34..10edcf8 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-04 Kimmo
+ PATCH: [ 765463 ] Simplify temp path handling a little
+  WinMerge: MergeDoc.h MergeDoc.cpp
+
 2003-07-03 Kimmo
  PATCH: [ 764571 ] Ask about saving when closing with esc
   WinMerge: MainFrm.cpp MergeDoc.cpp MergeEditView.cpp