9 CTGitPath(const CString
& sUnknownPath
);
13 LOGACTIONS_ADDED
= 0x00000001,
14 LOGACTIONS_MODIFIED
= 0x00000002,
15 LOGACTIONS_REPLACED
= 0x00000004,
16 LOGACTIONS_DELETED
= 0x00000008,
17 LOGACTIONS_UNVER
= 0x80000000,
18 LOGACTIONS_IGNORE
= 0x40000000,
25 int ParserAction(CString action
);
26 CString
GetActionName();
28 * Set the path as an UTF8 string with forward slashes
30 void SetFromGit(const char* pPath
);
31 void SetFromGit(const char* pPath
, bool bIsDirectory
);
32 void SetFromGit(const CString
& sPath
);
34 * Set the path as UNICODE with backslashes
36 void SetFromWin(LPCTSTR pPath
);
37 void SetFromWin(const CString
& sPath
);
38 void SetFromWin(const CString
& sPath
, bool bIsDirectory
);
40 * Set the path from an unknown source.
42 void SetFromUnknown(const CString
& sPath
);
44 * Returns the path in Windows format, i.e. with backslashes
46 LPCTSTR
GetWinPath() const;
48 * Returns the path in Windows format, i.e. with backslashes
50 const CString
& GetWinPathString() const;
52 * Returns the path with forward slashes.
54 const CString
& GetGitPathString() const;
56 * Returns the path completely prepared to be fed the the Git APIs
57 * It will be in UTF8, with URLs escaped, if necessary
59 // const char* GetGitApiPath(apr_pool_t *pool) const;
61 * Returns the path for showing in an UI.
63 * URL's are returned with forward slashes, unescaped if necessary
64 * Paths are returned with backward slashes
66 const CString
& GetUIPathString() const;
68 * Checks if the path is an URL.
72 * Returns true if the path points to a directory
74 bool IsDirectory() const;
76 * Returns the directory. If the path points to a directory, then the path
77 * is returned unchanged. If the path points to a file, the path to the
78 * parent directory is returned.
80 CTGitPath
GetDirectory() const;
82 * Returns the the directory which contains the item the path refers to.
83 * If the path is a directory, then this returns the directory above it.
84 * If the path is to a file, then this returns the directory which contains the path
85 * parent directory is returned.
87 CTGitPath
GetContainingDirectory() const;
89 * Get the 'root path' (e.g. "c:\") - Used to pass to GetDriveType
91 CString
GetRootPathString() const;
93 * Returns the filename part of the full path.
94 * \remark don't call this for directories.
96 CString
GetFilename() const;
97 CString
GetBaseFilename() const;
99 * Returns the item's name without the full path.
101 CString
GetFileOrDirectoryName() const;
103 * Returns the item's name without the full path, unescaped if necessary.
105 CString
GetUIFileOrDirectoryName() const;
107 * Returns the file extension, including the dot.
108 * \remark Returns an empty string for directories
110 CString
GetFileExtension() const;
112 bool IsEmpty() const;
115 * Checks if two paths are equal. The slashes are taken care of.
117 bool IsEquivalentTo(const CTGitPath
& rhs
) const;
118 bool IsEquivalentToWithoutCase(const CTGitPath
& rhs
) const;
119 bool operator==(const CTGitPath
& x
) const {return IsEquivalentTo(x
);}
122 * Checks if \c possibleDescendant is a child of this path.
124 bool IsAncestorOf(const CTGitPath
& possibleDescendant
) const;
126 * Get a string representing the file path, optionally with a base
127 * section stripped off the front
128 * Returns a string with fwdslash paths
130 CString
GetDisplayString(const CTGitPath
* pOptionalBasePath
= NULL
) const;
132 * Compares two paths. Slash format is irrelevant.
134 static int Compare(const CTGitPath
& left
, const CTGitPath
& right
);
136 /** As PredLeftLessThanRight, but for checking if paths are equivalent
138 static bool PredLeftEquivalentToRight(const CTGitPath
& left
, const CTGitPath
& right
);
140 /** Checks if the left path is pointing to the same working copy path as the right.
141 * The same wc path means the paths are equivalent once all the admin dir path parts
142 * are removed. This is used in the TGitCache crawler to filter out all the 'duplicate'
145 static bool PredLeftSameWCPathAsRight(const CTGitPath
& left
, const CTGitPath
& right
);
147 static bool CheckChild(const CTGitPath
&parent
, const CTGitPath
& child
);
150 * appends a string to this path.
151 *\remark - missing slashes are not added - this is just a string concatenation, but with
152 * preservation of the proper caching behavior.
153 * If you want to join a file- or directory-name onto the path, you should use AppendPathString
155 void AppendRawString(const CString
& sAppend
);
158 * appends a part of a path to this path.
159 *\remark - missing slashes are dealt with properly. Don't use this to append a file extension, for example
162 void AppendPathString(const CString
& sAppend
);
165 * Get the file modification time - returns zero for files which don't exist
166 * Returns a FILETIME structure cast to an __int64, for easy comparisons
168 __int64
GetLastWriteTime() const;
170 bool IsReadOnly() const;
173 * Checks if the path really exists.
178 * Deletes the file/folder
179 * \param bTrash if true, uses the Windows trash bin when deleting.
181 bool Delete(bool bTrash
) const;
184 * Checks if a Subversion admin directory is present. For files, the check
185 * is done in the same directory. For folders, it checks if the folder itself
186 * contains an admin directory.
188 bool HasAdminDir() const;
191 * Checks if the path point to or below a Subversion admin directory (.Git).
193 bool IsAdminDir() const;
195 void SetCustomData(LPARAM lp
) {m_customData
= lp
;}
196 LPARAM
GetCustomData() {return m_customData
;}
199 * Checks if the path or URL is valid on Windows.
200 * A path is valid if conforms to the specs in the windows API.
201 * An URL is valid if the path checked out from it is valid
202 * on windows. That means an URL which is valid according to the WWW specs
203 * isn't necessarily valid as a windows path (e.g. http://myserver.com/repos/file:name
204 * is a valid URL, but the path is illegal on windows ("file:name" is illegal), so
205 * this function would return \c false for that URL).
207 bool IsValidOnWindows() const;
210 * Checks to see if the path or URL represents one of the special directories
211 * (branches, tags, or trunk).
213 bool IsSpecialDirectory() const;
215 // All these functions are const, and all the data
216 // is mutable, in order that the hidden caching operations
217 // can be carried out on a const CTGitPath object, which is what's
218 // likely to be passed between functions
219 // The public 'SetFromxxx' functions are not const, and so the proper
220 // const-correctness semantics are preserved
221 void SetFwdslashPath(const CString
& sPath
) const;
222 void SetBackslashPath(const CString
& sPath
) const;
223 void SetUTF8FwdslashPath(const CString
& sPath
) const;
224 void EnsureBackslashPathSet() const;
225 void EnsureFwdslashPathSet() const;
227 * Checks if two path strings are equal. No conversion of slashes is done!
228 * \remark for slash-independent comparison, use IsEquivalentTo()
230 static bool ArePathStringsEqual(const CString
& sP1
, const CString
& sP2
);
231 static bool ArePathStringsEqualWithCase(const CString
& sP1
, const CString
& sP2
);
234 * Adds the required trailing slash to local root paths such as 'C:'
236 void SanitizeRootPath(CString
& sPath
, bool bIsForwardPath
) const;
238 void UpdateAttributes() const;
243 mutable CString m_sBackslashPath
;
244 mutable CString m_sFwdslashPath
;
245 mutable CString m_sUIPath
;
246 mutable CStringA m_sUTF8FwdslashPath
;
247 mutable CStringA m_sUTF8FwdslashPathEscaped
;
248 // Have we yet determined if this is a directory or not?
249 mutable bool m_bDirectoryKnown
;
250 mutable bool m_bIsDirectory
;
251 mutable bool m_bLastWriteTimeKnown
;
252 mutable bool m_bURLKnown
;
253 mutable bool m_bIsURL
;
254 mutable __int64 m_lastWriteTime
;
255 mutable bool m_bIsReadOnly
;
256 mutable bool m_bHasAdminDirKnown
;
257 mutable bool m_bHasAdminDir
;
258 mutable bool m_bIsValidOnWindowsKnown
;
259 mutable bool m_bIsValidOnWindows
;
260 mutable bool m_bIsAdminDirKnown
;
261 mutable bool m_bIsAdminDir
;
262 mutable bool m_bExists
;
263 mutable bool m_bExistsKnown
;
264 mutable LPARAM m_customData
;
265 mutable bool m_bIsSpecialDirectoryKnown
;
266 mutable bool m_bIsSpecialDirectory
;
268 friend bool operator<(const CTGitPath
& left
, const CTGitPath
& right
);
271 * Compares two paths and return true if left is earlier in sort order than right
272 * (Uses CTGitPath::Compare logic, but is suitable for std::sort and similar)
274 bool operator<(const CTGitPath
& left
, const CTGitPath
& right
);
277 //////////////////////////////////////////////////////////////////////////
281 * This class represents a list of paths
287 // A constructor which allows a path list to be easily built with one initial entry in
288 explicit CTGitPathList(const CTGitPath
& firstEntry
);
291 void AddPath(const CTGitPath
& newPath
);
292 bool LoadFromFile(const CTGitPath
& filename
);
293 bool WriteToFile(const CString
& sFilename
, bool bANSI
= false) const;
294 CTGitPath
* LookForGitPath(CString path
);
295 int ParserFromLog(CString
&log
);
296 int FillUnRev(int Action
);
299 * Load from the path argument string, when the 'path' parameter is used
300 * This is a list of paths, with '*' between them
302 void LoadFromAsteriskSeparatedString(const CString
& sPathString
);
303 CString
CreateAsteriskSeparatedString() const;
305 int GetCount() const;
307 const CTGitPath
& operator[](INT_PTR index
) const;
308 bool AreAllPathsFiles() const;
309 bool AreAllPathsFilesInOneDirectory() const;
310 CTGitPath
GetCommonDirectory() const;
311 CTGitPath
GetCommonRoot() const;
312 void SortByPathname(bool bReverse
= false);
314 * Delete all the files in the list, then clear the list.
315 * \param bTrash if true, the items are deleted using the Windows trash bin
317 void DeleteAllFiles(bool bTrash
);
318 /** Remove duplicate entries from the list (sorts the list as a side-effect */
319 void RemoveDuplicates();
320 /** Removes all paths which are on or in a Subversion admin directory */
321 void RemoveAdminPaths();
322 void RemovePath(const CTGitPath
& path
);
323 void RemoveItem(CTGitPath
&path
);
325 * Removes all child items and leaves only the top folders. Useful if you
326 * create the list to remove them (i.e. if you remove a parent folder, the
327 * child files and folders don't have to be deleted anymore)
329 void RemoveChildren();
331 /** Checks if two CTGitPathLists are the same */
332 bool IsEqual(const CTGitPathList
& list
);
334 /** Convert into the Git API parameter format */
335 // apr_array_header_t * MakePathArray (apr_pool_t *pool) const;
338 typedef std::vector
<CTGitPath
> PathVector
;
340 // If the list contains just files in one directory, then
341 // this contains the directory name
342 mutable CTGitPath m_commonBaseDirectory
;