OSDN Git Service

Add Setting Dialog
[tortoisegit/TortoiseGitJp.git] / src / Utils / PathUtils.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 /**\r
22  * \ingroup Utils\r
23  * helper class to handle path strings.\r
24  */\r
25 class CPathUtils\r
26 {\r
27 public:\r
28         static BOOL                     MakeSureDirectoryPathExists(LPCTSTR path);\r
29         static void                     ConvertToBackslash(LPTSTR dest, LPCTSTR src, size_t len);\r
30         /**\r
31          * Replaces escaped sequences with the corresponding characters in a string.\r
32          */\r
33         static void Unescape(char * psz);\r
34 \r
35         /**\r
36          * Replaces non-URI chars with the corresponding escape sequences.\r
37          */\r
38         static CStringA PathEscape(const CStringA& path);\r
39 \r
40 \r
41 #ifdef _MFC_VER\r
42         /**\r
43          * returns the filename of a full path\r
44          */\r
45         static CString GetFileNameFromPath(CString sPath);\r
46 \r
47         /**\r
48          * returns the file extension from a full path\r
49          */\r
50         static CString GetFileExtFromPath(const CString& sPath);\r
51 \r
52         /**\r
53          * Returns the long pathname of a path which may be in 8.3 format.\r
54          */\r
55         static CString GetLongPathname(const CString& path);\r
56 \r
57         /**\r
58          * Copies a file or a folder from \a srcPath to \a destpath, creating\r
59          * intermediate folders if necessary. If \a force is TRUE, then files\r
60          * are overwritten if they already exist.\r
61          * Folders are just created at the new location, no files in them get\r
62          * copied.\r
63          */\r
64         static BOOL FileCopy(CString srcPath, CString destPath, BOOL force = TRUE);\r
65 \r
66         /**\r
67          * parses a string for a path or url. If no path or url is found,\r
68          * an empty string is returned.\r
69          * \remark if more than one path or url is inside the string, only\r
70          * the first one is returned.\r
71          */\r
72         static CString ParsePathInString(const CString& Str);\r
73 \r
74         /**\r
75          * Returns the path to the installation folder, in our case the TortoiseSVN/bin folder.\r
76          * \remark the path returned has a trailing backslash\r
77          */\r
78         static CString GetAppDirectory();\r
79 \r
80         /**\r
81          * Returns the path to the installation parent folder, in our case the TortoiseSVN folder.\r
82          * \remark the path returned has a trailing backslash\r
83          */\r
84         static CString GetAppParentDirectory();\r
85 \r
86         /**\r
87          * Returns the path to the application data folder, in our case the %APPDATA%TortoiseSVN folder.\r
88          * \remark the path returned has a trailing backslash\r
89          */\r
90         static CString GetAppDataDirectory();\r
91 \r
92         /**\r
93          * Replaces escaped sequences with the corresponding characters in a string.\r
94          */\r
95         static CStringA PathUnescape(const CStringA& path);\r
96         static CStringW PathUnescape(const CStringW& path);\r
97 \r
98         /**\r
99         * Escapes regexp-specific chars.\r
100         */\r
101         static CString PathPatternEscape(const CString& path);\r
102         /**\r
103          * Unescapes regexp-specific chars.\r
104          */\r
105         static CString PathPatternUnEscape(const CString& path);\r
106 \r
107         /**\r
108          * Returns the version string from the VERSION resource of a dll or exe.\r
109          * \param p_strDateiname path to the dll or exe\r
110          * \return the version string\r
111          */\r
112         static CString GetVersionFromFile(const CString & p_strDateiname);\r
113 \r
114 \r
115 #endif\r
116 };\r