Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index cc10fad2b4..60238c3d8b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -67,6 +67,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.storage.file.LockFile;
+import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.MutableInteger;
import org.eclipse.jgit.util.NB;
@@ -129,7 +130,7 @@ public class DirCache {
* memory).
*/
public static DirCache newInCore() {
- return new DirCache(null);
+ return new DirCache(null, null);
}
/**
@@ -141,6 +142,9 @@ public class DirCache {
*
* @param indexLocation
* location of the index file on disk.
+ * @param fs
+ * the file system abstraction which will be necessary to perform
+ * certain file system operations.
* @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
@@ -149,9 +153,9 @@ public class DirCache {
* the index file is using a format or extension that this
* library does not support.
*/
- public static DirCache read(final File indexLocation)
+ public static DirCache read(final File indexLocation, final FS fs)
throws CorruptObjectException, IOException {
- final DirCache c = new DirCache(indexLocation);
+ final DirCache c = new DirCache(indexLocation, fs);
c.read();
return c;
}
@@ -161,11 +165,14 @@ public class DirCache {
* <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 method from returning a partially populated index. On read failure,
* the lock is released.
*
* @param indexLocation
* location of the index file on disk.
+ * @param fs
+ * the file system abstraction which will be necessary to perform
+ * certain file system operations.
* @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
@@ -175,9 +182,9 @@ public class DirCache {
* the index file is using a format or extension that this
* library does not support.
*/
- public static DirCache lock(final File indexLocation)
+ public static DirCache lock(final File indexLocation, final FS fs)
throws CorruptObjectException, IOException {
- final DirCache c = new DirCache(indexLocation);
+ final DirCache c = new DirCache(indexLocation, fs);
if (!c.lock())
throw new IOException(MessageFormat.format(JGitText.get().cannotLock, indexLocation));
@@ -215,6 +222,9 @@ public class DirCache {
/** Our active lock (if we hold it); null if we don't have it locked. */
private LockFile myLock;
+ /** file system abstraction **/
+ private final FS fs;
+
/**
* Create a new in-core index representation.
* <p>
@@ -223,9 +233,13 @@ public class DirCache {
*
* @param indexLocation
* location of the index file on disk.
+ * @param fs
+ * the file system abstraction which will be necessary to perform
+ * certain file system operations.
*/
- public DirCache(final File indexLocation) {
+ public DirCache(final File indexLocation, final FS fs) {
liveFile = indexLocation;
+ this.fs = fs;
clear();
}
@@ -429,7 +443,7 @@ public class DirCache {
public boolean lock() throws IOException {
if (liveFile == null)
throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile);
- final LockFile tmp = new LockFile(liveFile);
+ final LockFile tmp = new LockFile(liveFile, fs);
if (tmp.lock()) {
tmp.setNeedStatInformation(true);
myLock = tmp;

Back to the top