9 CTGitPath(const CString
& sUnknownPath
);
14 LOGACTIONS_ADDED
= 0x00000001,
15 LOGACTIONS_MODIFIED
= 0x00000002,
16 LOGACTIONS_REPLACED
= 0x00000004,
17 LOGACTIONS_DELETED
= 0x00000008,
18 LOGACTIONS_UNMERGED
= 0x00000010,
19 LOGACTIONS_CACHE
= 0x00000020,
20 LOGACTIONS_COPY
= 0x00000040,
21 LOGACTIONS_UNVER
= 0x80000000,
22 LOGACTIONS_IGNORE
= 0x40000000,
23 //LOGACTIONS_CONFLICT = 0x20000000,
25 // For log filter only
26 LOGACTIONS_HIDE
= 0x20000000,
27 LOGACTIONS_GRAY
= 0x10000000,
30 LOGACTIONS_REBASE_CURRENT
= 0x08000000,
31 LOGACTIONS_REBASE_PICK
= 0x04000000,
32 LOGACTIONS_REBASE_SQUASH
= 0x02000000,
33 LOGACTIONS_REBASE_EDIT
= 0x01000000,
34 LOGACTIONS_REBASE_MASK
= 0x0F000000,
35 LOGACTIONS_REBASE_MODE_MASK
=0x07000000,
43 int ParserAction(BYTE action
);
44 CString
GetActionName();
46 * Set the path as an UTF8 string with forward slashes
48 void SetFromGit(const char* pPath
);
49 void SetFromGit(const char* pPath
, bool bIsDirectory
);
50 void SetFromGit(const CString
& sPath
,CString
*OldPath
=NULL
);
53 * Set the path as UNICODE with backslashes
55 void SetFromWin(LPCTSTR pPath
);
56 void SetFromWin(const CString
& sPath
);
57 void SetFromWin(const CString
& sPath
, bool bIsDirectory
);
59 * Set the path from an unknown source.
61 void SetFromUnknown(const CString
& sPath
);
63 * Returns the path in Windows format, i.e. with backslashes
65 LPCTSTR
GetWinPath() const;
67 * Returns the path in Windows format, i.e. with backslashes
69 const CString
& GetWinPathString() const;
71 * Returns the path with forward slashes.
73 const CString
& GetGitPathString() const;
75 const CString
& GetGitOldPathString() const;
77 * Returns the path completely prepared to be fed the the Git APIs
78 * It will be in UTF8, with URLs escaped, if necessary
80 // const char* GetGitApiPath(apr_pool_t *pool) const;
82 * Returns the path for showing in an UI.
84 * URL's are returned with forward slashes, unescaped if necessary
85 * Paths are returned with backward slashes
87 const CString
& GetUIPathString() const;
89 * Checks if the path is an URL.
93 * Returns true if the path points to a directory
95 bool IsDirectory() const;
97 * Returns the directory. If the path points to a directory, then the path
98 * is returned unchanged. If the path points to a file, the path to the
99 * parent directory is returned.
101 CTGitPath
GetDirectory() const;
103 * Returns the the directory which contains the item the path refers to.
104 * If the path is a directory, then this returns the directory above it.
105 * If the path is to a file, then this returns the directory which contains the path
106 * parent directory is returned.
108 CTGitPath
GetContainingDirectory() const;
110 * Get the 'root path' (e.g. "c:\") - Used to pass to GetDriveType
112 CString
GetRootPathString() const;
114 * Returns the filename part of the full path.
115 * \remark don't call this for directories.
117 CString
GetFilename() const;
118 CString
GetBaseFilename() const;
120 * Returns the item's name without the full path.
122 CString
GetFileOrDirectoryName() const;
124 * Returns the item's name without the full path, unescaped if necessary.
126 CString
GetUIFileOrDirectoryName() const;
128 * Returns the file extension, including the dot.
129 * \remark Returns an empty string for directories
131 CString
GetFileExtension() const;
133 bool IsEmpty() const;
136 * Checks if two paths are equal. The slashes are taken care of.
138 bool IsEquivalentTo(const CTGitPath
& rhs
) const;
139 bool IsEquivalentToWithoutCase(const CTGitPath
& rhs
) const;
140 bool operator==(const CTGitPath
& x
) const {return IsEquivalentTo(x
);}
143 * Checks if \c possibleDescendant is a child of this path.
145 bool IsAncestorOf(const CTGitPath
& possibleDescendant
) const;
147 * Get a string representing the file path, optionally with a base
148 * section stripped off the front
149 * Returns a string with fwdslash paths
151 CString
GetDisplayString(const CTGitPath
* pOptionalBasePath
= NULL
) const;
153 * Compares two paths. Slash format is irrelevant.
155 static int Compare(const CTGitPath
& left
, const CTGitPath
& right
);
157 /** As PredLeftLessThanRight, but for checking if paths are equivalent
159 static bool PredLeftEquivalentToRight(const CTGitPath
& left
, const CTGitPath
& right
);
161 /** Checks if the left path is pointing to the same working copy path as the right.
162 * The same wc path means the paths are equivalent once all the admin dir path parts
163 * are removed. This is used in the TGitCache crawler to filter out all the 'duplicate'
166 static bool PredLeftSameWCPathAsRight(const CTGitPath
& left
, const CTGitPath
& right
);
168 static bool CheckChild(const CTGitPath
&parent
, const CTGitPath
& child
);
171 * appends a string to this path.
172 *\remark - missing slashes are not added - this is just a string concatenation, but with
173 * preservation of the proper caching behavior.
174 * If you want to join a file- or directory-name onto the path, you should use AppendPathString
176 void AppendRawString(const CString
& sAppend
);
179 * appends a part of a path to this path.
180 *\remark - missing slashes are dealt with properly. Don't use this to append a file extension, for example
183 void AppendPathString(const CString
& sAppend
);
186 * Get the file modification time - returns zero for files which don't exist
187 * Returns a FILETIME structure cast to an __int64, for easy comparisons
189 __int64
GetLastWriteTime() const;
191 bool IsReadOnly() const;
194 * Checks if the path really exists.
199 * Deletes the file/folder
200 * \param bTrash if true, uses the Windows trash bin when deleting.
202 bool Delete(bool bTrash
) const;
205 * Checks if a Subversion admin directory is present. For files, the check
206 * is done in the same directory. For folders, it checks if the folder itself
207 * contains an admin directory.
209 bool HasAdminDir() const;
210 bool HasAdminDir(CString
*ProjectTopDir
) const;
213 * Checks if the path point to or below a Subversion admin directory (.Git).
215 bool IsAdminDir() const;
217 void SetCustomData(LPARAM lp
) {m_customData
= lp
;}
218 LPARAM
GetCustomData() {return m_customData
;}
221 * Checks if the path or URL is valid on Windows.
222 * A path is valid if conforms to the specs in the windows API.
223 * An URL is valid if the path checked out from it is valid
224 * on windows. That means an URL which is valid according to the WWW specs
225 * isn't necessarily valid as a windows path (e.g. http://myserver.com/repos/file:name
226 * is a valid URL, but the path is illegal on windows ("file:name" is illegal), so
227 * this function would return \c false for that URL).
229 bool IsValidOnWindows() const;
232 * Checks to see if the path or URL represents one of the special directories
233 * (branches, tags, or trunk).
235 bool IsSpecialDirectory() const;
237 // All these functions are const, and all the data
238 // is mutable, in order that the hidden caching operations
239 // can be carried out on a const CTGitPath object, which is what's
240 // likely to be passed between functions
241 // The public 'SetFromxxx' functions are not const, and so the proper
242 // const-correctness semantics are preserved
243 void SetFwdslashPath(const CString
& sPath
) const;
244 void SetBackslashPath(const CString
& sPath
) const;
245 void SetUTF8FwdslashPath(const CString
& sPath
) const;
246 void EnsureBackslashPathSet() const;
247 void EnsureFwdslashPathSet() const;
249 * Checks if two path strings are equal. No conversion of slashes is done!
250 * \remark for slash-independent comparison, use IsEquivalentTo()
252 static bool ArePathStringsEqual(const CString
& sP1
, const CString
& sP2
);
253 static bool ArePathStringsEqualWithCase(const CString
& sP1
, const CString
& sP2
);
256 * Adds the required trailing slash to local root paths such as 'C:'
258 void SanitizeRootPath(CString
& sPath
, bool bIsForwardPath
) const;
260 void UpdateAttributes() const;
265 mutable CString m_sBackslashPath
;
266 mutable CString m_sFwdslashPath
;
267 mutable CString m_sUIPath
;
268 mutable CStringA m_sUTF8FwdslashPath
;
269 mutable CStringA m_sUTF8FwdslashPathEscaped
;
270 mutable CString m_sProjectRoot
;
272 //used for rename case
273 mutable CString m_sOldBackslashPath
;
274 mutable CString m_sOldFwdslashPath
;
276 // Have we yet determined if this is a directory or not?
277 mutable bool m_bDirectoryKnown
;
278 mutable bool m_bIsDirectory
;
279 mutable bool m_bLastWriteTimeKnown
;
280 mutable bool m_bURLKnown
;
281 mutable bool m_bIsURL
;
282 mutable __int64 m_lastWriteTime
;
283 mutable bool m_bIsReadOnly
;
284 mutable bool m_bHasAdminDirKnown
;
285 mutable bool m_bHasAdminDir
;
286 mutable bool m_bIsValidOnWindowsKnown
;
287 mutable bool m_bIsValidOnWindows
;
288 mutable bool m_bIsAdminDirKnown
;
289 mutable bool m_bIsAdminDir
;
290 mutable bool m_bExists
;
291 mutable bool m_bExistsKnown
;
292 mutable LPARAM m_customData
;
293 mutable bool m_bIsSpecialDirectoryKnown
;
294 mutable bool m_bIsSpecialDirectory
;
296 friend bool operator<(const CTGitPath
& left
, const CTGitPath
& right
);
299 * Compares two paths and return true if left is earlier in sort order than right
300 * (Uses CTGitPath::Compare logic, but is suitable for std::sort and similar)
302 bool operator<(const CTGitPath
& left
, const CTGitPath
& right
);
305 //////////////////////////////////////////////////////////////////////////
309 * This class represents a list of paths
315 // A constructor which allows a path list to be easily built with one initial entry in
316 explicit CTGitPathList(const CTGitPath
& firstEntry
);
320 void AddPath(const CTGitPath
& newPath
);
321 bool LoadFromFile(const CTGitPath
& filename
);
322 bool WriteToFile(const CString
& sFilename
, bool bANSI
= false) const;
323 CTGitPath
* LookForGitPath(CString path
);
324 int ParserFromLog(BYTE_VECTOR
&log
);
325 int ParserFromLsFile(BYTE_VECTOR
&out
,bool staged
=true);
326 int FillUnRev(int Action
,CTGitPathList
*list
=NULL
);
329 * Load from the path argument string, when the 'path' parameter is used
330 * This is a list of paths, with '*' between them
332 void LoadFromAsteriskSeparatedString(const CString
& sPathString
);
333 CString
CreateAsteriskSeparatedString() const;
335 int GetCount() const;
337 const CTGitPath
& operator[](INT_PTR index
) const;
338 bool AreAllPathsFiles() const;
339 bool AreAllPathsFilesInOneDirectory() const;
340 CTGitPath
GetCommonDirectory() const;
341 CTGitPath
GetCommonRoot() const;
342 void SortByPathname(bool bReverse
= false);
344 * Delete all the files in the list, then clear the list.
345 * \param bTrash if true, the items are deleted using the Windows trash bin
347 void DeleteAllFiles(bool bTrash
);
348 /** Remove duplicate entries from the list (sorts the list as a side-effect */
349 void RemoveDuplicates();
350 /** Removes all paths which are on or in a Subversion admin directory */
351 void RemoveAdminPaths();
352 void RemovePath(const CTGitPath
& path
);
353 void RemoveItem(CTGitPath
&path
);
355 * Removes all child items and leaves only the top folders. Useful if you
356 * create the list to remove them (i.e. if you remove a parent folder, the
357 * child files and folders don't have to be deleted anymore)
359 void RemoveChildren();
361 /** Checks if two CTGitPathLists are the same */
362 bool IsEqual(const CTGitPathList
& list
);
364 /** Convert into the Git API parameter format */
365 // apr_array_header_t * MakePathArray (apr_pool_t *pool) const;
368 typedef std::vector
<CTGitPath
> PathVector
;
370 // If the list contains just files in one directory, then
371 // this contains the directory name
372 mutable CTGitPath m_commonBaseDirectory
;