8 CTGitPath(const CString& sUnknownPath);
\r
12 LOGACTIONS_ADDED = 0x00000001,
\r
13 LOGACTIONS_MODIFIED = 0x00000002,
\r
14 LOGACTIONS_REPLACED = 0x00000004,
\r
15 LOGACTIONS_DELETED = 0x00000008,
\r
16 LOGACTIONS_UNVER = 0x80000000,
\r
17 LOGACTIONS_IGNORE = 0x40000000,
\r
24 int ParserAction(CString action);
\r
25 CString GetActionName();
\r
27 * Set the path as an UTF8 string with forward slashes
\r
29 void SetFromGit(const char* pPath);
\r
30 void SetFromGit(const char* pPath, bool bIsDirectory);
\r
31 void SetFromGit(const CString& sPath);
\r
33 * Set the path as UNICODE with backslashes
\r
35 void SetFromWin(LPCTSTR pPath);
\r
36 void SetFromWin(const CString& sPath);
\r
37 void SetFromWin(const CString& sPath, bool bIsDirectory);
\r
39 * Set the path from an unknown source.
\r
41 void SetFromUnknown(const CString& sPath);
\r
43 * Returns the path in Windows format, i.e. with backslashes
\r
45 LPCTSTR GetWinPath() const;
\r
47 * Returns the path in Windows format, i.e. with backslashes
\r
49 const CString& GetWinPathString() const;
\r
51 * Returns the path with forward slashes.
\r
53 const CString& GetGitPathString() const;
\r
55 * Returns the path completely prepared to be fed the the Git APIs
\r
56 * It will be in UTF8, with URLs escaped, if necessary
\r
58 // const char* GetGitApiPath(apr_pool_t *pool) const;
\r
60 * Returns the path for showing in an UI.
\r
62 * URL's are returned with forward slashes, unescaped if necessary
\r
63 * Paths are returned with backward slashes
\r
65 const CString& GetUIPathString() const;
\r
67 * Checks if the path is an URL.
\r
71 * Returns true if the path points to a directory
\r
73 bool IsDirectory() const;
\r
75 * Returns the directory. If the path points to a directory, then the path
\r
76 * is returned unchanged. If the path points to a file, the path to the
\r
77 * parent directory is returned.
\r
79 CTGitPath GetDirectory() const;
\r
81 * Returns the the directory which contains the item the path refers to.
\r
82 * If the path is a directory, then this returns the directory above it.
\r
83 * If the path is to a file, then this returns the directory which contains the path
\r
84 * parent directory is returned.
\r
86 CTGitPath GetContainingDirectory() const;
\r
88 * Get the 'root path' (e.g. "c:\") - Used to pass to GetDriveType
\r
90 CString GetRootPathString() const;
\r
92 * Returns the filename part of the full path.
\r
93 * \remark don't call this for directories.
\r
95 CString GetFilename() const;
\r
96 CString GetBaseFilename() const;
\r
98 * Returns the item's name without the full path.
\r
100 CString GetFileOrDirectoryName() const;
\r
102 * Returns the item's name without the full path, unescaped if necessary.
\r
104 CString GetUIFileOrDirectoryName() const;
\r
106 * Returns the file extension, including the dot.
\r
107 * \remark Returns an empty string for directories
\r
109 CString GetFileExtension() const;
\r
111 bool IsEmpty() const;
\r
114 * Checks if two paths are equal. The slashes are taken care of.
\r
116 bool IsEquivalentTo(const CTGitPath& rhs) const;
\r
117 bool IsEquivalentToWithoutCase(const CTGitPath& rhs) const;
\r
118 bool operator==(const CTGitPath& x) const {return IsEquivalentTo(x);}
\r
121 * Checks if \c possibleDescendant is a child of this path.
\r
123 bool IsAncestorOf(const CTGitPath& possibleDescendant) const;
\r
125 * Get a string representing the file path, optionally with a base
\r
126 * section stripped off the front
\r
127 * Returns a string with fwdslash paths
\r
129 CString GetDisplayString(const CTGitPath* pOptionalBasePath = NULL) const;
\r
131 * Compares two paths. Slash format is irrelevant.
\r
133 static int Compare(const CTGitPath& left, const CTGitPath& right);
\r
135 /** As PredLeftLessThanRight, but for checking if paths are equivalent
\r
137 static bool PredLeftEquivalentToRight(const CTGitPath& left, const CTGitPath& right);
\r
139 /** Checks if the left path is pointing to the same working copy path as the right.
\r
140 * The same wc path means the paths are equivalent once all the admin dir path parts
\r
141 * are removed. This is used in the TGitCache crawler to filter out all the 'duplicate'
\r
144 static bool PredLeftSameWCPathAsRight(const CTGitPath& left, const CTGitPath& right);
\r
146 static bool CheckChild(const CTGitPath &parent, const CTGitPath& child);
\r
149 * appends a string to this path.
\r
150 *\remark - missing slashes are not added - this is just a string concatenation, but with
\r
151 * preservation of the proper caching behavior.
\r
152 * If you want to join a file- or directory-name onto the path, you should use AppendPathString
\r
154 void AppendRawString(const CString& sAppend);
\r
157 * appends a part of a path to this path.
\r
158 *\remark - missing slashes are dealt with properly. Don't use this to append a file extension, for example
\r
161 void AppendPathString(const CString& sAppend);
\r
164 * Get the file modification time - returns zero for files which don't exist
\r
165 * Returns a FILETIME structure cast to an __int64, for easy comparisons
\r
167 __int64 GetLastWriteTime() const;
\r
169 bool IsReadOnly() const;
\r
172 * Checks if the path really exists.
\r
174 bool Exists() const;
\r
177 * Deletes the file/folder
\r
178 * \param bTrash if true, uses the Windows trash bin when deleting.
\r
180 bool Delete(bool bTrash) const;
\r
183 * Checks if a Subversion admin directory is present. For files, the check
\r
184 * is done in the same directory. For folders, it checks if the folder itself
\r
185 * contains an admin directory.
\r
187 bool HasAdminDir() const;
\r
190 * Checks if the path point to or below a Subversion admin directory (.Git).
\r
192 bool IsAdminDir() const;
\r
194 void SetCustomData(LPARAM lp) {m_customData = lp;}
\r
195 LPARAM GetCustomData() {return m_customData;}
\r
198 * Checks if the path or URL is valid on Windows.
\r
199 * A path is valid if conforms to the specs in the windows API.
\r
200 * An URL is valid if the path checked out from it is valid
\r
201 * on windows. That means an URL which is valid according to the WWW specs
\r
202 * isn't necessarily valid as a windows path (e.g. http://myserver.com/repos/file:name
\r
203 * is a valid URL, but the path is illegal on windows ("file:name" is illegal), so
\r
204 * this function would return \c false for that URL).
\r
206 bool IsValidOnWindows() const;
\r
209 * Checks to see if the path or URL represents one of the special directories
\r
210 * (branches, tags, or trunk).
\r
212 bool IsSpecialDirectory() const;
\r
214 // All these functions are const, and all the data
\r
215 // is mutable, in order that the hidden caching operations
\r
216 // can be carried out on a const CTGitPath object, which is what's
\r
217 // likely to be passed between functions
\r
218 // The public 'SetFromxxx' functions are not const, and so the proper
\r
219 // const-correctness semantics are preserved
\r
220 void SetFwdslashPath(const CString& sPath) const;
\r
221 void SetBackslashPath(const CString& sPath) const;
\r
222 void SetUTF8FwdslashPath(const CString& sPath) const;
\r
223 void EnsureBackslashPathSet() const;
\r
224 void EnsureFwdslashPathSet() const;
\r
226 * Checks if two path strings are equal. No conversion of slashes is done!
\r
227 * \remark for slash-independent comparison, use IsEquivalentTo()
\r
229 static bool ArePathStringsEqual(const CString& sP1, const CString& sP2);
\r
230 static bool ArePathStringsEqualWithCase(const CString& sP1, const CString& sP2);
\r
233 * Adds the required trailing slash to local root paths such as 'C:'
\r
235 void SanitizeRootPath(CString& sPath, bool bIsForwardPath) const;
\r
237 void UpdateAttributes() const;
\r
242 mutable CString m_sBackslashPath;
\r
243 mutable CString m_sFwdslashPath;
\r
244 mutable CString m_sUIPath;
\r
245 mutable CStringA m_sUTF8FwdslashPath;
\r
246 mutable CStringA m_sUTF8FwdslashPathEscaped;
\r
247 // Have we yet determined if this is a directory or not?
\r
248 mutable bool m_bDirectoryKnown;
\r
249 mutable bool m_bIsDirectory;
\r
250 mutable bool m_bLastWriteTimeKnown;
\r
251 mutable bool m_bURLKnown;
\r
252 mutable bool m_bIsURL;
\r
253 mutable __int64 m_lastWriteTime;
\r
254 mutable bool m_bIsReadOnly;
\r
255 mutable bool m_bHasAdminDirKnown;
\r
256 mutable bool m_bHasAdminDir;
\r
257 mutable bool m_bIsValidOnWindowsKnown;
\r
258 mutable bool m_bIsValidOnWindows;
\r
259 mutable bool m_bIsAdminDirKnown;
\r
260 mutable bool m_bIsAdminDir;
\r
261 mutable bool m_bExists;
\r
262 mutable bool m_bExistsKnown;
\r
263 mutable LPARAM m_customData;
\r
264 mutable bool m_bIsSpecialDirectoryKnown;
\r
265 mutable bool m_bIsSpecialDirectory;
\r
267 friend bool operator<(const CTGitPath& left, const CTGitPath& right);
\r
270 * Compares two paths and return true if left is earlier in sort order than right
\r
271 * (Uses CTGitPath::Compare logic, but is suitable for std::sort and similar)
\r
273 bool operator<(const CTGitPath& left, const CTGitPath& right);
\r
276 //////////////////////////////////////////////////////////////////////////
\r
280 * This class represents a list of paths
\r
282 class CTGitPathList
\r
286 // A constructor which allows a path list to be easily built with one initial entry in
\r
287 explicit CTGitPathList(const CTGitPath& firstEntry);
\r
290 void AddPath(const CTGitPath& newPath);
\r
291 bool LoadFromFile(const CTGitPath& filename);
\r
292 bool WriteToFile(const CString& sFilename, bool bANSI = false) const;
\r
293 CTGitPath * LookForGitPath(CString path);
\r
294 int ParserFromLog(CString &log);
\r
295 int FillUnRev(int Action);
\r
298 * Load from the path argument string, when the 'path' parameter is used
\r
299 * This is a list of paths, with '*' between them
\r
301 void LoadFromAsteriskSeparatedString(const CString& sPathString);
\r
302 CString CreateAsteriskSeparatedString() const;
\r
304 int GetCount() const;
\r
306 const CTGitPath& operator[](INT_PTR index) const;
\r
307 bool AreAllPathsFiles() const;
\r
308 bool AreAllPathsFilesInOneDirectory() const;
\r
309 CTGitPath GetCommonDirectory() const;
\r
310 CTGitPath GetCommonRoot() const;
\r
311 void SortByPathname(bool bReverse = false);
\r
313 * Delete all the files in the list, then clear the list.
\r
314 * \param bTrash if true, the items are deleted using the Windows trash bin
\r
316 void DeleteAllFiles(bool bTrash);
\r
317 /** Remove duplicate entries from the list (sorts the list as a side-effect */
\r
318 void RemoveDuplicates();
\r
319 /** Removes all paths which are on or in a Subversion admin directory */
\r
320 void RemoveAdminPaths();
\r
321 void RemovePath(const CTGitPath& path);
\r
322 void RemoveItem(CTGitPath &path);
\r
324 * Removes all child items and leaves only the top folders. Useful if you
\r
325 * create the list to remove them (i.e. if you remove a parent folder, the
\r
326 * child files and folders don't have to be deleted anymore)
\r
328 void RemoveChildren();
\r
330 /** Checks if two CTGitPathLists are the same */
\r
331 bool IsEqual(const CTGitPathList& list);
\r
333 /** Convert into the Git API parameter format */
\r
334 // apr_array_header_t * MakePathArray (apr_pool_t *pool) const;
\r
337 typedef std::vector<CTGitPath> PathVector;
\r
338 PathVector m_paths;
\r
339 // If the list contains just files in one directory, then
\r
340 // this contains the directory name
\r
341 mutable CTGitPath m_commonBaseDirectory;
\r