10 * Set the path as an UTF8 string with forward slashes
\r
12 void SetFromGit(const char* pPath);
\r
13 void SetFromGit(const char* pPath, bool bIsDirectory);
\r
14 void SetFromGit(const CString& sPath);
\r
16 * Set the path as UNICODE with backslashes
\r
18 void SetFromWin(LPCTSTR pPath);
\r
19 void SetFromWin(const CString& sPath);
\r
20 void SetFromWin(const CString& sPath, bool bIsDirectory);
\r
22 * Set the path from an unknown source.
\r
24 void SetFromUnknown(const CString& sPath);
\r
26 * Returns the path in Windows format, i.e. with backslashes
\r
28 LPCTSTR GetWinPath() const;
\r
30 * Returns the path in Windows format, i.e. with backslashes
\r
32 const CString& GetWinPathString() const;
\r
34 * Returns the path with forward slashes.
\r
36 const CString& GetGitPathString() const;
\r
38 * Returns the path completely prepared to be fed the the Git APIs
\r
39 * It will be in UTF8, with URLs escaped, if necessary
\r
41 // const char* GetGitApiPath(apr_pool_t *pool) const;
\r
43 * Returns the path for showing in an UI.
\r
45 * URL's are returned with forward slashes, unescaped if necessary
\r
46 * Paths are returned with backward slashes
\r
48 const CString& GetUIPathString() const;
\r
50 * Checks if the path is an URL.
\r
54 * Returns true if the path points to a directory
\r
56 bool IsDirectory() const;
\r
58 * Returns the directory. If the path points to a directory, then the path
\r
59 * is returned unchanged. If the path points to a file, the path to the
\r
60 * parent directory is returned.
\r
62 CTGitPath GetDirectory() const;
\r
64 * Returns the the directory which contains the item the path refers to.
\r
65 * If the path is a directory, then this returns the directory above it.
\r
66 * If the path is to a file, then this returns the directory which contains the path
\r
67 * parent directory is returned.
\r
69 CTGitPath GetContainingDirectory() const;
\r
71 * Get the 'root path' (e.g. "c:\") - Used to pass to GetDriveType
\r
73 CString GetRootPathString() const;
\r
75 * Returns the filename part of the full path.
\r
76 * \remark don't call this for directories.
\r
78 CString GetFilename() const;
\r
80 * Returns the item's name without the full path.
\r
82 CString GetFileOrDirectoryName() const;
\r
84 * Returns the item's name without the full path, unescaped if necessary.
\r
86 CString GetUIFileOrDirectoryName() const;
\r
88 * Returns the file extension, including the dot.
\r
89 * \remark Returns an empty string for directories
\r
91 CString GetFileExtension() const;
\r
93 bool IsEmpty() const;
\r
96 * Checks if two paths are equal. The slashes are taken care of.
\r
98 bool IsEquivalentTo(const CTGitPath& rhs) const;
\r
99 bool IsEquivalentToWithoutCase(const CTGitPath& rhs) const;
\r
100 bool operator==(const CTGitPath& x) const {return IsEquivalentTo(x);}
\r
103 * Checks if \c possibleDescendant is a child of this path.
\r
105 bool IsAncestorOf(const CTGitPath& possibleDescendant) const;
\r
107 * Get a string representing the file path, optionally with a base
\r
108 * section stripped off the front
\r
109 * Returns a string with fwdslash paths
\r
111 CString GetDisplayString(const CTGitPath* pOptionalBasePath = NULL) const;
\r
113 * Compares two paths. Slash format is irrelevant.
\r
115 static int Compare(const CTGitPath& left, const CTGitPath& right);
\r
117 /** As PredLeftLessThanRight, but for checking if paths are equivalent
\r
119 static bool PredLeftEquivalentToRight(const CTGitPath& left, const CTGitPath& right);
\r
121 /** Checks if the left path is pointing to the same working copy path as the right.
\r
122 * The same wc path means the paths are equivalent once all the admin dir path parts
\r
123 * are removed. This is used in the TGitCache crawler to filter out all the 'duplicate'
\r
126 static bool PredLeftSameWCPathAsRight(const CTGitPath& left, const CTGitPath& right);
\r
128 static bool CheckChild(const CTGitPath &parent, const CTGitPath& child);
\r
131 * appends a string to this path.
\r
132 *\remark - missing slashes are not added - this is just a string concatenation, but with
\r
133 * preservation of the proper caching behavior.
\r
134 * If you want to join a file- or directory-name onto the path, you should use AppendPathString
\r
136 void AppendRawString(const CString& sAppend);
\r
139 * appends a part of a path to this path.
\r
140 *\remark - missing slashes are dealt with properly. Don't use this to append a file extension, for example
\r
143 void AppendPathString(const CString& sAppend);
\r
146 * Get the file modification time - returns zero for files which don't exist
\r
147 * Returns a FILETIME structure cast to an __int64, for easy comparisons
\r
149 __int64 GetLastWriteTime() const;
\r
151 bool IsReadOnly() const;
\r
154 * Checks if the path really exists.
\r
156 bool Exists() const;
\r
159 * Deletes the file/folder
\r
160 * \param bTrash if true, uses the Windows trash bin when deleting.
\r
162 bool Delete(bool bTrash) const;
\r
165 * Checks if a Subversion admin directory is present. For files, the check
\r
166 * is done in the same directory. For folders, it checks if the folder itself
\r
167 * contains an admin directory.
\r
169 bool HasAdminDir() const;
\r
172 * Checks if the path point to or below a Subversion admin directory (.Git).
\r
174 bool IsAdminDir() const;
\r
176 void SetCustomData(LPARAM lp) {m_customData = lp;}
\r
177 LPARAM GetCustomData() {return m_customData;}
\r
180 * Checks if the path or URL is valid on Windows.
\r
181 * A path is valid if conforms to the specs in the windows API.
\r
182 * An URL is valid if the path checked out from it is valid
\r
183 * on windows. That means an URL which is valid according to the WWW specs
\r
184 * isn't necessarily valid as a windows path (e.g. http://myserver.com/repos/file:name
\r
185 * is a valid URL, but the path is illegal on windows ("file:name" is illegal), so
\r
186 * this function would return \c false for that URL).
\r
188 bool IsValidOnWindows() const;
\r
191 * Checks to see if the path or URL represents one of the special directories
\r
192 * (branches, tags, or trunk).
\r
194 bool IsSpecialDirectory() const;
\r
196 // All these functions are const, and all the data
\r
197 // is mutable, in order that the hidden caching operations
\r
198 // can be carried out on a const CTGitPath object, which is what's
\r
199 // likely to be passed between functions
\r
200 // The public 'SetFromxxx' functions are not const, and so the proper
\r
201 // const-correctness semantics are preserved
\r
202 void SetFwdslashPath(const CString& sPath) const;
\r
203 void SetBackslashPath(const CString& sPath) const;
\r
204 void SetUTF8FwdslashPath(const CString& sPath) const;
\r
205 void EnsureBackslashPathSet() const;
\r
206 void EnsureFwdslashPathSet() const;
\r
208 * Checks if two path strings are equal. No conversion of slashes is done!
\r
209 * \remark for slash-independent comparison, use IsEquivalentTo()
\r
211 static bool ArePathStringsEqual(const CString& sP1, const CString& sP2);
\r
212 static bool ArePathStringsEqualWithCase(const CString& sP1, const CString& sP2);
\r
215 * Adds the required trailing slash to local root paths such as 'C:'
\r
217 void SanitizeRootPath(CString& sPath, bool bIsForwardPath) const;
\r
219 void UpdateAttributes() const;
\r
222 mutable CString m_sBackslashPath;
\r
223 mutable CString m_sFwdslashPath;
\r
224 mutable CString m_sUIPath;
\r
225 mutable CStringA m_sUTF8FwdslashPath;
\r
226 mutable CStringA m_sUTF8FwdslashPathEscaped;
\r
227 // Have we yet determined if this is a directory or not?
\r
228 mutable bool m_bDirectoryKnown;
\r
229 mutable bool m_bIsDirectory;
\r
230 mutable bool m_bLastWriteTimeKnown;
\r
231 mutable bool m_bURLKnown;
\r
232 mutable bool m_bIsURL;
\r
233 mutable __int64 m_lastWriteTime;
\r
234 mutable bool m_bIsReadOnly;
\r
235 mutable bool m_bHasAdminDirKnown;
\r
236 mutable bool m_bHasAdminDir;
\r
237 mutable bool m_bIsValidOnWindowsKnown;
\r
238 mutable bool m_bIsValidOnWindows;
\r
239 mutable bool m_bIsAdminDirKnown;
\r
240 mutable bool m_bIsAdminDir;
\r
241 mutable bool m_bExists;
\r
242 mutable bool m_bExistsKnown;
\r
243 mutable LPARAM m_customData;
\r
244 mutable bool m_bIsSpecialDirectoryKnown;
\r
245 mutable bool m_bIsSpecialDirectory;
\r
247 friend bool operator<(const CTGitPath& left, const CTGitPath& right);
\r
250 * Compares two paths and return true if left is earlier in sort order than right
\r
251 * (Uses CTGitPath::Compare logic, but is suitable for std::sort and similar)
\r
253 bool operator<(const CTGitPath& left, const CTGitPath& right);
\r
256 //////////////////////////////////////////////////////////////////////////
\r
260 * This class represents a list of paths
\r
262 class CTGitPathList
\r
266 // A constructor which allows a path list to be easily built with one initial entry in
\r
267 explicit CTGitPathList(const CTGitPath& firstEntry);
\r
270 void AddPath(const CTGitPath& newPath);
\r
271 bool LoadFromFile(const CTGitPath& filename);
\r
272 bool WriteToFile(const CString& sFilename, bool bANSI = false) const;
\r
275 * Load from the path argument string, when the 'path' parameter is used
\r
276 * This is a list of paths, with '*' between them
\r
278 void LoadFromAsteriskSeparatedString(const CString& sPathString);
\r
279 CString CreateAsteriskSeparatedString() const;
\r
281 int GetCount() const;
\r
283 const CTGitPath& operator[](INT_PTR index) const;
\r
284 bool AreAllPathsFiles() const;
\r
285 bool AreAllPathsFilesInOneDirectory() const;
\r
286 CTGitPath GetCommonDirectory() const;
\r
287 CTGitPath GetCommonRoot() const;
\r
288 void SortByPathname(bool bReverse = false);
\r
290 * Delete all the files in the list, then clear the list.
\r
291 * \param bTrash if true, the items are deleted using the Windows trash bin
\r
293 void DeleteAllFiles(bool bTrash);
\r
294 /** Remove duplicate entries from the list (sorts the list as a side-effect */
\r
295 void RemoveDuplicates();
\r
296 /** Removes all paths which are on or in a Subversion admin directory */
\r
297 void RemoveAdminPaths();
\r
298 void RemovePath(const CTGitPath& path);
\r
300 * Removes all child items and leaves only the top folders. Useful if you
\r
301 * create the list to remove them (i.e. if you remove a parent folder, the
\r
302 * child files and folders don't have to be deleted anymore)
\r
304 void RemoveChildren();
\r
306 /** Checks if two CTGitPathLists are the same */
\r
307 bool IsEqual(const CTGitPathList& list);
\r
309 /** Convert into the Git API parameter format */
\r
310 // apr_array_header_t * MakePathArray (apr_pool_t *pool) const;
\r
313 typedef std::vector<CTGitPath> PathVector;
\r
314 PathVector m_paths;
\r
315 // If the list contains just files in one directory, then
\r
316 // this contains the directory name
\r
317 mutable CTGitPath m_commonBaseDirectory;
\r