Make sure member variables are initialized correctly
[TortoiseGit.git] / src / Utils / PathUtils.h
blob3ec82fc8ddc1034e7132892ad08e20de01bf3e2b
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008, 2013-2014 - 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.
19 #pragma once
21 #if defined(_MFC_VER)
22 // CSTRING is always available in an MFC build
23 #define CSTRING_AVAILABLE
24 #endif
26 /**
27 * \ingroup Utils
28 * helper class to handle path strings.
30 class CPathUtils
32 public:
33 static BOOL MakeSureDirectoryPathExists(LPCTSTR path);
34 static void ConvertToBackslash(LPTSTR dest, LPCTSTR src, size_t len);
35 /**
36 * Replaces escaped sequences with the corresponding characters in a string.
38 static void Unescape(char * psz);
40 /**
41 * Replaces non-URI chars with the corresponding escape sequences.
43 static CStringA PathEscape(const CStringA& path);
46 #ifdef CSTRING_AVAILABLE
47 /**
48 * returns the filename of a full path
50 static CString GetFileNameFromPath(CString sPath);
52 /**
53 * returns the file extension from a full path
55 static CString GetFileExtFromPath(const CString& sPath);
57 /**
58 * Returns the long pathname of a path which may be in 8.3 format.
60 static CString GetLongPathname(const CString& path);
62 /**
63 * Copies a file or a folder from \a srcPath to \a destpath, creating
64 * intermediate folders if necessary. If \a force is TRUE, then files
65 * are overwritten if they already exist.
66 * Folders are just created at the new location, no files in them get
67 * copied.
69 static BOOL FileCopy(CString srcPath, CString destPath, BOOL force = TRUE);
71 /**
72 * parses a string for a path or url. If no path or url is found,
73 * an empty string is returned.
74 * \remark if more than one path or url is inside the string, only
75 * the first one is returned.
77 static CString ParsePathInString(const CString& Str);
79 /**
80 * Returns the path to the installation folder, in our case the TortoiseSVN/bin folder.
81 * \remark the path returned has a trailing backslash
83 static CString GetAppDirectory(HMODULE hMod = NULL);
85 /**
86 * Returns the path to the installation parent folder, in our case the TortoiseSVN folder.
87 * \remark the path returned has a trailing backslash
89 static CString GetAppParentDirectory(HMODULE hMod = NULL);
91 /**
92 * Returns the path to the application data folder, in our case the %APPDATA%TortoiseSVN folder.
93 * \remark the path returned has a trailing backslash
95 static CString GetAppDataDirectory();
96 static CString GetLocalAppDataDirectory();
98 /**
99 * Replaces escaped sequences with the corresponding characters in a string.
101 static CStringA PathUnescape(const CStringA& path);
102 static CStringW PathUnescape(const CStringW& path);
105 * Escapes regexp-specific chars.
107 static CString PathPatternEscape(const CString& path);
109 * Unescapes regexp-specific chars.
111 static CString PathPatternUnEscape(const CString& path);
114 * Returns the version string from the VERSION resource of a dll or exe.
115 * \param p_strFilename path to the dll or exe
116 * \return the version string
118 static CString GetVersionFromFile(const CString & p_strFilename);
121 #endif