示例#1
0
 /**
  * Create a new in-core index representation, lock it, and read from disk.
  *
  * <p>The new index will be locked and then read before it is returned to the caller. Read
  * failures are reported as exceptions and therefore prevent the method from returning a partially
  * populated index. On read failure, the lock is released.
  *
  * @param repository repository containing the index to lock and read
  * @param indexChangedListener listener to be informed when DirCache is committed
  * @return a cache representing the contents of the specified index file (if it exists) or an
  *     empty cache if the file does not exist.
  * @throws IOException the index file is present but could not be read, or the lock could not be
  *     obtained.
  * @throws CorruptObjectException the index file is using a format or extension that this library
  *     does not support.
  * @since 2.0
  */
 public static DirCache lock(
     final Repository repository, final IndexChangedListener indexChangedListener)
     throws CorruptObjectException, IOException {
   DirCache c = lock(repository.getIndexFile(), repository.getFS(), indexChangedListener);
   c.repository = repository;
   return c;
 }
示例#2
0
 private boolean isInIndex(Repository db, String path) throws IOException {
   DirCache dc = DirCache.read(db.getIndexFile(), db.getFS());
   return dc.getEntry(path) != null;
 }
示例#3
0
  public int getDirCacheEntryLength(String path) throws IOException {
    String repoPath = getRepoRelativePath(path);
    DirCache dc = DirCache.read(repository.getIndexFile(), repository.getFS());

    return dc.getEntry(repoPath).getLength();
  }
示例#4
0
  public long lastModifiedInIndex(String path) throws IOException {
    String repoPath = getRepoRelativePath(path);
    DirCache dc = DirCache.read(repository.getIndexFile(), repository.getFS());

    return dc.getEntry(repoPath).getLastModified();
  }
示例#5
0
  public boolean inIndex(String path) throws IOException {
    String repoPath = getRepoRelativePath(path);
    DirCache dc = DirCache.read(repository.getIndexFile(), repository.getFS());

    return dc.getEntry(repoPath) != null;
  }
示例#6
0
 /**
  * Create a new in-core index representation and read an index from disk.
  *
  * <p>The new index will be read before it is returned to the caller. Read failures are reported
  * as exceptions and therefore prevent the method from returning a partially populated index.
  *
  * @param repository repository containing the index to read
  * @return a cache representing the contents of the specified index file (if it exists) or an
  *     empty cache if the file does not exist.
  * @throws IOException the index file is present but could not be read.
  * @throws CorruptObjectException the index file is using a format or extension that this library
  *     does not support.
  */
 public static DirCache read(final Repository repository)
     throws CorruptObjectException, IOException {
   final DirCache c = read(repository.getIndexFile(), repository.getFS());
   c.repository = repository;
   return c;
 }