1 // TortoiseGitMerge - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006,2008,2010 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * This singleton class handles temporary files.
27 * All temp files are deleted at the end of a run of SVN operations
32 static CTempFiles
& Instance();
35 * Returns a path to a temporary file.
36 * \param bRemoveAtEnd if true, the temp file is removed when this object
38 * \param path if set, the temp file will have the same file extension
40 * \param revision if set, the temp file name will include the revision number
42 CTGitPath
GetTempFilePath(bool bRemoveAtEnd
, const CTGitPath
& path
= CTGitPath());
43 CString
GetTempFilePathString();
46 * Returns a path to a temporary directory.
47 * \param bRemoveAtEnd if true, the temp directory is removed when this object
49 * \param path if set, the temp directory will have the same file extension
51 * \param revision if set, the temp directory name will include the revision number
53 CTGitPath
GetTempDirPath(bool bRemoveAtEnd
, const CTGitPath
& path
= CTGitPath());
55 // Look for temporary files left around by TortoiseMerge and
56 // remove them. But only delete 'old' files
57 static void DeleteOldTempFiles(LPCWSTR wildCard
);
59 void AddFileToRemove(const CString
& file
) { m_TempFileList
.AddPath(CTGitPath(file
)); }
63 // try to allocate an unused temp file / dir at most MAX_RETRIES times
65 enum {MAX_RETRIES
= 100};
67 // list of paths to delete when terminating the app
69 CTGitPathList m_TempFileList
;
71 // actual implementation
73 CTGitPath
ConstructTempPath(const CTGitPath
& path
);
74 CTGitPath
CreateTempPath (bool bRemoveAtEnd
, const CTGitPath
& path
, bool directory
);
76 // construction / destruction