Package org.eclipse.jgit.lib
Class FileModeCache
- java.lang.Object
-
- org.eclipse.jgit.lib.FileModeCache
-
public class FileModeCache extends java.lang.Object
A hierarchical cache ofFileMode
s per git path.- Since:
- 6.6.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileModeCache.CacheItem
An item from aFileModeCache
, recording information about a git path (known from context).
-
Field Summary
Fields Modifier and Type Field Description private Repository
repo
private FileModeCache.CacheItem
root
-
Constructor Summary
Constructors Constructor Description FileModeCache(Repository repo)
Creates a newFileModeCache
for aRepository
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private FileModeCache.CacheItem
add(java.lang.String gitPath, FileMode finalMode)
Records the givenFileMode
for the given git path in the cache.private void
deleteSymlinkParent(FS fs, java.lang.String gitPath, java.io.File workingTree)
Repository
getRepository()
Retrieves theRepository
.FileModeCache.CacheItem
getRoot()
Obtains theFileModeCache.CacheItem
for the working tree root.FileModeCache.CacheItem
safeCreateDirectory(java.lang.String gitPath, java.io.File dir, boolean makeSpace)
Ensures the given directorydir
with the given git path exists.void
safeCreateParentDirectory(java.lang.String gitPath, java.io.File parentDir, boolean makeSpace)
Ensure that the given parent directory exists, and cache the information that gitPath refers to a file.
-
-
-
Field Detail
-
root
@NonNull private final FileModeCache.CacheItem root
-
repo
@NonNull private final Repository repo
-
-
Constructor Detail
-
FileModeCache
public FileModeCache(@NonNull Repository repo)
Creates a newFileModeCache
for aRepository
.- Parameters:
repo
-Repository
this cache is for
-
-
Method Detail
-
getRepository
@NonNull public Repository getRepository()
Retrieves theRepository
.- Returns:
- the
Repository
thisFileModeCache
was created for
-
getRoot
@NonNull public FileModeCache.CacheItem getRoot()
Obtains theFileModeCache.CacheItem
for the working tree root.- Returns:
- the
FileModeCache.CacheItem
-
safeCreateParentDirectory
public void safeCreateParentDirectory(java.lang.String gitPath, java.io.File parentDir, boolean makeSpace) throws java.io.IOException
Ensure that the given parent directory exists, and cache the information that gitPath refers to a file.- Parameters:
gitPath
- of the file to be writtenparentDir
- directory in which the file shall be placed, assumed to be the parent of thegitPath
makeSpace
- whether to delete a possibly existing file atparentDir
- Throws:
java.io.IOException
- if the directory cannot be created, if necessary
-
safeCreateDirectory
public FileModeCache.CacheItem safeCreateDirectory(java.lang.String gitPath, java.io.File dir, boolean makeSpace) throws java.io.IOException
Ensures the given directorydir
with the given git path exists.- Parameters:
gitPath
- of a file to be writtendir
- directory in which the file shall be placed, assumed to be the parent of thegitPath
makeSpace
- whether to remove a file that already at that name- Returns:
- A
FileModeCache.CacheItem
describing the directory, which is guaranteed to exist - Throws:
java.io.IOException
- if the directory cannot be made to exist at the given location
-
deleteSymlinkParent
private void deleteSymlinkParent(FS fs, java.lang.String gitPath, java.io.File workingTree) throws java.io.IOException
- Throws:
java.io.IOException
-
add
@NonNull private FileModeCache.CacheItem add(java.lang.String gitPath, FileMode finalMode)
Records the givenFileMode
for the given git path in the cache. If an entry already exists for the given path, the previously cached file mode is overwritten.- Parameters:
gitPath
- to cache theFileMode
forfinalMode
-FileMode
to cache- Returns:
- the
FileModeCache.CacheItem
for the path
-
-