package nl.weeaboo.filesystem;

import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicBoolean;

public abstract class AbstractFileSystem implements IFileSystem {

    private AtomicBoolean closed = new AtomicBoolean();

    protected AbstractFileSystem() {
    }

    /**
     * @param path The user-specified path.
     */
    protected FilePath resolvePath(FilePath path) {
        return path;
    }

    @Override
    public final void close() {
        if (closed.compareAndSet(false, true)) {
            closeImpl();
        }
    }

    protected abstract void closeImpl();

    @Override
    public boolean isOpen() {
        return !closed.get();
    }

    @Override
    public final InputStream openInputStream(FilePath path) throws IOException {
        return openInputStreamImpl(resolvePath(path));
    }

    protected abstract InputStream openInputStreamImpl(FilePath path) throws IOException;

    @Override
    public final boolean getFileExists(FilePath path) {
        return getFileExistsImpl(resolvePath(path));
    }

    protected abstract boolean getFileExistsImpl(FilePath path);

    @Override
    public final long getFileSize(FilePath path) throws IOException {
        return getFileSizeImpl(resolvePath(path));
    }

    protected abstract long getFileSizeImpl(FilePath path) throws IOException;

    @Override
    public final long getFileModifiedTime(FilePath path) throws IOException {
        return getFileModifiedTimeImpl(resolvePath(path));
    }

    protected abstract long getFileModifiedTimeImpl(FilePath path) throws IOException;

}

@@ -25,16 +25,54 @@
 ystem;%0A%0A
+import java.io.FileNotFoundException;%0A
 import j
@@ -334,24 +334,561 @@
 () %7B%0A    %7D%0A%0A
+    /**%0A     * @param allowNonExistant If %7B@code true%7D, allow paths to non-existant files.%0A     * @throws FileNotFoundException If %7B@code allowNonExistant%7D is false and the path doesn't point to a%0A     *         valid file.%0A     * @deprecated Replaced with %7B@link #resolvePath(FilePath)%7D. The %7B@code allowNonExistant%7D flag was never%0A     *             really used.%0A     */%0A    @Deprecated%0A    protected FilePath resolvePath(FilePath path, boolean allowNonExistant) throws FileNotFoundException %7B%0A        return resolvePath(path);%0A    %7D%0A%0A
     /**%0A    

Add deprecated method delegate to avoid a breaking API change