4 #define PARENT_MASK 0xFFFFFF
5 #define MERGE_MASK (0x1000000)
12 CTGitPath(const CString
& sUnknownPath
);
18 LOGACTIONS_ADDED
= 0x00000001,
19 LOGACTIONS_MODIFIED
= 0x00000002,
20 LOGACTIONS_REPLACED
= 0x00000004,
21 LOGACTIONS_DELETED
= 0x00000008,
22 LOGACTIONS_UNMERGED
= 0x00000010,
23 LOGACTIONS_CACHE
= 0x00000020,
24 LOGACTIONS_COPY
= 0x00000040,
25 LOGACTIONS_MERGED
= 0x00000080,
26 LOGACTIONS_FORWORD
= 0x00000100,
27 LOGACTIONS_UNVER
= 0x80000000,
28 LOGACTIONS_IGNORE
= 0x40000000,
29 //LOGACTIONS_CONFLICT = 0x20000000,
31 // For log filter only
32 LOGACTIONS_HIDE
= 0x20000000,
33 LOGACTIONS_GRAY
= 0x10000000,
36 LOGACTIONS_REBASE_CURRENT
= 0x08000000,
37 LOGACTIONS_REBASE_PICK
= 0x04000000,
38 LOGACTIONS_REBASE_SQUASH
= 0x02000000,
39 LOGACTIONS_REBASE_EDIT
= 0x01000000,
40 LOGACTIONS_REBASE_DONE
= 0x00800000,
41 LOGACTIONS_REBASE_SKIP
= 0x00400000,
42 LOGACTIONS_REBASE_MASK
= 0x0FC00000,
43 LOGACTIONS_REBASE_MODE_MASK
=0x07C00000,
51 int ParserAction(BYTE action
);
52 CString
GetActionName();
53 static CString
GetActionName(int action
);
55 * Set the path as an UTF8 string with forward slashes
57 void SetFromGit(const char* pPath
);
58 void SetFromGit(const char* pPath
, bool bIsDirectory
);
59 void SetFromGit(const TCHAR
* pPath
, bool bIsDirectory
);
60 void SetFromGit(const CString
& sPath
,CString
*OldPath
=NULL
);
63 * Set the path as UNICODE with backslashes
65 void SetFromWin(LPCTSTR pPath
);
66 void SetFromWin(const CString
& sPath
);
67 void SetFromWin(const CString
& sPath
, bool bIsDirectory
);
69 * Set the path from an unknown source.
71 void SetFromUnknown(const CString
& sPath
);
73 * Returns the path in Windows format, i.e. with backslashes
75 LPCTSTR
GetWinPath() const;
77 * Returns the path in Windows format, i.e. with backslashes
79 const CString
& GetWinPathString() const;
81 * Returns the path with forward slashes.
83 const CString
& GetGitPathString() const;
85 const CString
& GetGitOldPathString() const;
87 * Returns the path completely prepared to be fed the the Git APIs
88 * It will be in UTF8, with URLs escaped, if necessary
90 // const char* GetGitApiPath(apr_pool_t *pool) const;
92 * Returns the path for showing in an UI.
94 * URL's are returned with forward slashes, unescaped if necessary
95 * Paths are returned with backward slashes
97 const CString
& GetUIPathString() const;
99 * Checks if the path is an URL.
103 * Returns true if the path points to a directory
105 bool IsDirectory() const;
107 CTGitPath
GetSubPath(const CTGitPath
&root
);
110 * Returns the directory. If the path points to a directory, then the path
111 * is returned unchanged. If the path points to a file, the path to the
112 * parent directory is returned.
114 CTGitPath
GetDirectory() const;
116 * Returns the the directory which contains the item the path refers to.
117 * If the path is a directory, then this returns the directory above it.
118 * If the path is to a file, then this returns the directory which contains the path
119 * parent directory is returned.
121 CTGitPath
GetContainingDirectory() const;
123 * Get the 'root path' (e.g. "c:\") - Used to pass to GetDriveType
125 CString
GetRootPathString() const;
127 * Returns the filename part of the full path.
128 * \remark don't call this for directories.
130 CString
GetFilename() const;
131 CString
GetBaseFilename() const;
133 * Returns the item's name without the full path.
135 CString
GetFileOrDirectoryName() const;
137 * Returns the item's name without the full path, unescaped if necessary.
139 CString
GetUIFileOrDirectoryName() const;
141 * Returns the file extension, including the dot.
142 * \remark Returns an empty string for directories
144 CString
GetFileExtension() const;
146 bool IsEmpty() const;
149 * Checks if two paths are equal. The slashes are taken care of.
151 bool IsEquivalentTo(const CTGitPath
& rhs
) const;
152 bool IsEquivalentToWithoutCase(const CTGitPath
& rhs
) const;
153 bool operator==(const CTGitPath
& x
) const {return IsEquivalentTo(x
);}
156 * Checks if \c possibleDescendant is a child of this path.
158 bool IsAncestorOf(const CTGitPath
& possibleDescendant
) const;
160 * Get a string representing the file path, optionally with a base
161 * section stripped off the front
162 * Returns a string with fwdslash paths
164 CString
GetDisplayString(const CTGitPath
* pOptionalBasePath
= NULL
) const;
166 * Compares two paths. Slash format is irrelevant.
168 static int Compare(const CTGitPath
& left
, const CTGitPath
& right
);
170 /** As PredLeftLessThanRight, but for checking if paths are equivalent
172 static bool PredLeftEquivalentToRight(const CTGitPath
& left
, const CTGitPath
& right
);
174 /** Checks if the left path is pointing to the same working copy path as the right.
175 * The same wc path means the paths are equivalent once all the admin dir path parts
176 * are removed. This is used in the TGitCache crawler to filter out all the 'duplicate'
179 static bool PredLeftSameWCPathAsRight(const CTGitPath
& left
, const CTGitPath
& right
);
181 static bool CheckChild(const CTGitPath
&parent
, const CTGitPath
& child
);
184 * appends a string to this path.
185 *\remark - missing slashes are not added - this is just a string concatenation, but with
186 * preservation of the proper caching behavior.
187 * If you want to join a file- or directory-name onto the path, you should use AppendPathString
189 void AppendRawString(const CString
& sAppend
);
192 * appends a part of a path to this path.
193 *\remark - missing slashes are dealt with properly. Don't use this to append a file extension, for example
196 void AppendPathString(const CString
& sAppend
);
199 * Get the file modification time - returns zero for files which don't exist
200 * Returns a FILETIME structure cast to an __int64, for easy comparisons
202 __int64
GetLastWriteTime() const;
204 bool IsReadOnly() const;
207 * Checks if the path really exists.
212 * Deletes the file/folder
213 * \param bTrash if true, uses the Windows trash bin when deleting.
215 bool Delete(bool bTrash
) const;
218 * Checks if a Subversion admin directory is present. For files, the check
219 * is done in the same directory. For folders, it checks if the folder itself
220 * contains an admin directory.
222 bool HasAdminDir() const;
223 bool HasAdminDir(CString
*ProjectTopDir
) const;
224 bool HasSubmodules() const;
225 bool HasGitSVNDir() const;
226 bool HasStashDir() const;
227 bool HasRebaseApply() const;
229 int GetAdminDirMask() const;
232 * Checks if the path point to or below a Subversion admin directory (.Git).
234 bool IsAdminDir() const;
236 void SetCustomData(LPARAM lp
) {m_customData
= lp
;}
237 LPARAM
GetCustomData() {return m_customData
;}
240 * Checks if the path or URL is valid on Windows.
241 * A path is valid if conforms to the specs in the windows API.
242 * An URL is valid if the path checked out from it is valid
243 * on windows. That means an URL which is valid according to the WWW specs
244 * isn't necessarily valid as a windows path (e.g. http://myserver.com/repos/file:name
245 * is a valid URL, but the path is illegal on windows ("file:name" is illegal), so
246 * this function would return \c false for that URL).
248 bool IsValidOnWindows() const;
251 * Checks to see if the path or URL represents one of the special directories
252 * (branches, tags, or trunk).
254 bool IsSpecialDirectory() const;
256 // All these functions are const, and all the data
257 // is mutable, in order that the hidden caching operations
258 // can be carried out on a const CTGitPath object, which is what's
259 // likely to be passed between functions
260 // The public 'SetFromxxx' functions are not const, and so the proper
261 // const-correctness semantics are preserved
262 void SetFwdslashPath(const CString
& sPath
) const;
263 void SetBackslashPath(const CString
& sPath
) const;
264 void SetUTF8FwdslashPath(const CString
& sPath
) const;
265 void EnsureBackslashPathSet() const;
266 void EnsureFwdslashPathSet() const;
268 * Checks if two path strings are equal. No conversion of slashes is done!
269 * \remark for slash-independent comparison, use IsEquivalentTo()
271 static bool ArePathStringsEqual(const CString
& sP1
, const CString
& sP2
);
272 static bool ArePathStringsEqualWithCase(const CString
& sP1
, const CString
& sP2
);
275 * Adds the required trailing slash to local root paths such as 'C:'
277 void SanitizeRootPath(CString
& sPath
, bool bIsForwardPath
) const;
279 void UpdateAttributes() const;
284 mutable CString m_sBackslashPath
;
285 mutable CString m_sFwdslashPath
;
286 mutable CString m_sUIPath
;
287 mutable CStringA m_sUTF8FwdslashPath
;
288 mutable CStringA m_sUTF8FwdslashPathEscaped
;
289 mutable CString m_sProjectRoot
;
291 //used for rename case
292 mutable CString m_sOldBackslashPath
;
293 mutable CString m_sOldFwdslashPath
;
295 // Have we yet determined if this is a directory or not?
296 mutable bool m_bDirectoryKnown
;
297 mutable bool m_bIsDirectory
;
298 mutable bool m_bLastWriteTimeKnown
;
299 mutable bool m_bURLKnown
;
300 mutable bool m_bIsURL
;
301 mutable __int64 m_lastWriteTime
;
302 mutable bool m_bIsReadOnly
;
303 mutable bool m_bHasAdminDirKnown
;
304 mutable bool m_bHasAdminDir
;
305 mutable bool m_bIsValidOnWindowsKnown
;
306 mutable bool m_bIsValidOnWindows
;
307 mutable bool m_bIsAdminDirKnown
;
308 mutable bool m_bIsAdminDir
;
309 mutable bool m_bExists
;
310 mutable bool m_bExistsKnown
;
311 mutable LPARAM m_customData
;
312 mutable bool m_bIsSpecialDirectoryKnown
;
313 mutable bool m_bIsSpecialDirectory
;
315 friend bool operator<(const CTGitPath
& left
, const CTGitPath
& right
);
318 * Compares two paths and return true if left is earlier in sort order than right
319 * (Uses CTGitPath::Compare logic, but is suitable for std::sort and similar)
321 bool operator<(const CTGitPath
& left
, const CTGitPath
& right
);
324 //////////////////////////////////////////////////////////////////////////
328 * This class represents a list of paths
334 // A constructor which allows a path list to be easily built with one initial entry in
335 explicit CTGitPathList(const CTGitPath
& firstEntry
);
339 void AddPath(const CTGitPath
& newPath
);
340 bool LoadFromFile(const CTGitPath
& filename
);
341 bool WriteToFile(const CString
& sFilename
, bool bANSI
= false) const;
342 CTGitPath
* LookForGitPath(CString path
);
343 int ParserFromLog(BYTE_VECTOR
&log
);
344 int ParserFromLsFile(BYTE_VECTOR
&out
,bool staged
=true);
345 int FillUnRev(int Action
,CTGitPathList
*list
=NULL
);
348 * Load from the path argument string, when the 'path' parameter is used
349 * This is a list of paths, with '*' between them
351 void LoadFromAsteriskSeparatedString(const CString
& sPathString
);
352 CString
CreateAsteriskSeparatedString() const;
354 int GetCount() const;
356 const CTGitPath
& operator[](INT_PTR index
) const;
357 bool AreAllPathsFiles() const;
358 bool AreAllPathsFilesInOneDirectory() const;
359 CTGitPath
GetCommonDirectory() const;
360 CTGitPath
GetCommonRoot() const;
361 void SortByPathname(bool bReverse
= false);
363 * Delete all the files in the list, then clear the list.
364 * \param bTrash if true, the items are deleted using the Windows trash bin
366 void DeleteAllFiles(bool bTrash
);
367 /** Remove duplicate entries from the list (sorts the list as a side-effect */
368 void RemoveDuplicates();
369 /** Removes all paths which are on or in a Subversion admin directory */
370 void RemoveAdminPaths();
371 void RemovePath(const CTGitPath
& path
);
372 void RemoveItem(CTGitPath
&path
);
374 * Removes all child items and leaves only the top folders. Useful if you
375 * create the list to remove them (i.e. if you remove a parent folder, the
376 * child files and folders don't have to be deleted anymore)
378 void RemoveChildren();
380 /** Checks if two CTGitPathLists are the same */
381 bool IsEqual(const CTGitPathList
& list
);
383 /** Convert into the Git API parameter format */
384 // apr_array_header_t * MakePathArray (apr_pool_t *pool) const;
386 typedef std::vector
<CTGitPath
> PathVector
;
388 // If the list contains just files in one directory, then
389 // this contains the directory name
390 mutable CTGitPath m_commonBaseDirectory
;