1 // TortoiseGit - 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.
22 // CSTRING is always available in an MFC build
23 #define CSTRING_AVAILABLE
28 * helper class to handle path strings.
33 static BOOL
MakeSureDirectoryPathExists(LPCTSTR path
);
34 static void ConvertToBackslash(LPTSTR dest
, LPCTSTR src
, size_t len
);
36 * Replaces escaped sequences with the corresponding characters in a string.
38 static void Unescape(char * psz
);
41 * Replaces non-URI chars with the corresponding escape sequences.
43 static CStringA
PathEscape(const CStringA
& path
);
46 #ifdef CSTRING_AVAILABLE
48 * returns the filename of a full path
50 static CString
GetFileNameFromPath(CString sPath
);
53 * returns the file extension from a full path
55 static CString
GetFileExtFromPath(const CString
& sPath
);
58 * Returns the long pathname of a path which may be in 8.3 format.
60 static CString
GetLongPathname(const CString
& path
);
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
69 static BOOL
FileCopy(CString srcPath
, CString destPath
, BOOL force
= TRUE
);
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
);
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
);
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
);
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();
98 * Replaces escaped sequences with the corresponding characters in a string.
100 static CStringA
PathUnescape(const CStringA
& path
);
101 static CStringW
PathUnescape(const CStringW
& path
);
104 * Escapes regexp-specific chars.
106 static CString
PathPatternEscape(const CString
& path
);
108 * Unescapes regexp-specific chars.
110 static CString
PathPatternUnEscape(const CString
& path
);
113 * Returns the version string from the VERSION resource of a dll or exe.
114 * \param p_strDateiname path to the dll or exe
115 * \return the version string
117 static CString
GetVersionFromFile(const CString
& p_strDateiname
);