Textual changes
[TortoiseGit.git] / src / Utils / PathUtils.h
blob911308eaeb87a54fd54e60e0a832c9de6512be25
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - 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 /**
22 * \ingroup Utils
23 * helper class to handle path strings.
25 class CPathUtils
27 public:
28 static BOOL MakeSureDirectoryPathExists(LPCTSTR path);
29 static void ConvertToBackslash(LPTSTR dest, LPCTSTR src, size_t len);
30 /**
31 * Replaces escaped sequences with the corresponding characters in a string.
33 static void Unescape(char * psz);
35 /**
36 * Replaces non-URI chars with the corresponding escape sequences.
38 static CStringA PathEscape(const CStringA& path);
41 #ifdef _MFC_VER
42 /**
43 * returns the filename of a full path
45 static CString GetFileNameFromPath(CString sPath);
47 /**
48 * returns the file extension from a full path
50 static CString GetFileExtFromPath(const CString& sPath);
52 /**
53 * Returns the long pathname of a path which may be in 8.3 format.
55 static CString GetLongPathname(const CString& path);
57 /**
58 * Copies a file or a folder from \a srcPath to \a destpath, creating
59 * intermediate folders if necessary. If \a force is TRUE, then files
60 * are overwritten if they already exist.
61 * Folders are just created at the new location, no files in them get
62 * copied.
64 static BOOL FileCopy(CString srcPath, CString destPath, BOOL force = TRUE);
66 /**
67 * parses a string for a path or url. If no path or url is found,
68 * an empty string is returned.
69 * \remark if more than one path or url is inside the string, only
70 * the first one is returned.
72 static CString ParsePathInString(const CString& Str);
74 /**
75 * Returns the path to the installation folder, in our case the TortoiseSVN/bin folder.
76 * \remark the path returned has a trailing backslash
78 static CString GetAppDirectory();
80 /**
81 * Returns the path to the installation parent folder, in our case the TortoiseSVN folder.
82 * \remark the path returned has a trailing backslash
84 static CString GetAppParentDirectory();
86 /**
87 * Returns the path to the application data folder, in our case the %APPDATA%TortoiseSVN folder.
88 * \remark the path returned has a trailing backslash
90 static CString GetAppDataDirectory();
92 /**
93 * Replaces escaped sequences with the corresponding characters in a string.
95 static CStringA PathUnescape(const CStringA& path);
96 static CStringW PathUnescape(const CStringW& path);
98 /**
99 * Escapes regexp-specific chars.
101 static CString PathPatternEscape(const CString& path);
103 * Unescapes regexp-specific chars.
105 static CString PathPatternUnEscape(const CString& path);
108 * Returns the version string from the VERSION resource of a dll or exe.
109 * \param p_strDateiname path to the dll or exe
110 * \return the version string
112 static CString GetVersionFromFile(const CString & p_strDateiname);
115 #endif