Search in sources :

Example 1 with FilterFileSystem

use of org.apache.lucene.mockfile.FilterFileSystem in project lucene-solr by apache.

the class TestUtil method hasVirusChecker.

public static boolean hasVirusChecker(Path path) {
    FileSystem fs = path.getFileSystem();
    while (fs instanceof FilterFileSystem) {
        FilterFileSystem ffs = (FilterFileSystem) fs;
        if (ffs.getParent() instanceof VirusCheckingFS) {
            return true;
        }
        fs = ffs.getDelegate();
    }
    return false;
}
Also used : FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) VirusCheckingFS(org.apache.lucene.mockfile.VirusCheckingFS)

Example 2 with FilterFileSystem

use of org.apache.lucene.mockfile.FilterFileSystem in project lucene-solr by apache.

the class TestUtil method enableVirusChecker.

public static void enableVirusChecker(Directory in) {
    Directory dir = FilterDirectory.unwrap(in);
    if (dir instanceof FSDirectory) {
        FileSystem fs = ((FSDirectory) dir).getDirectory().getFileSystem();
        while (fs instanceof FilterFileSystem) {
            FilterFileSystem ffs = (FilterFileSystem) fs;
            if (ffs.getParent() instanceof VirusCheckingFS) {
                VirusCheckingFS vfs = (VirusCheckingFS) ffs.getParent();
                vfs.enable();
                return;
            }
            fs = ffs.getDelegate();
        }
    }
}
Also used : FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FSDirectory(org.apache.lucene.store.FSDirectory) VirusCheckingFS(org.apache.lucene.mockfile.VirusCheckingFS) Directory(org.apache.lucene.store.Directory) RAMDirectory(org.apache.lucene.store.RAMDirectory) FSDirectory(org.apache.lucene.store.FSDirectory) FilterDirectory(org.apache.lucene.store.FilterDirectory)

Example 3 with FilterFileSystem

use of org.apache.lucene.mockfile.FilterFileSystem in project lucene-solr by apache.

the class TestUtil method disableVirusChecker.

/** Returns true if VirusCheckingFS is in use and was in fact already enabled */
public static boolean disableVirusChecker(Directory in) {
    Directory dir = FilterDirectory.unwrap(in);
    if (dir instanceof FSDirectory) {
        FileSystem fs = ((FSDirectory) dir).getDirectory().getFileSystem();
        while (fs instanceof FilterFileSystem) {
            FilterFileSystem ffs = (FilterFileSystem) fs;
            if (ffs.getParent() instanceof VirusCheckingFS) {
                VirusCheckingFS vfs = (VirusCheckingFS) ffs.getParent();
                boolean isEnabled = vfs.isEnabled();
                vfs.disable();
                return isEnabled;
            }
            fs = ffs.getDelegate();
        }
    }
    return false;
}
Also used : FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FSDirectory(org.apache.lucene.store.FSDirectory) VirusCheckingFS(org.apache.lucene.mockfile.VirusCheckingFS) Directory(org.apache.lucene.store.Directory) RAMDirectory(org.apache.lucene.store.RAMDirectory) FSDirectory(org.apache.lucene.store.FSDirectory) FilterDirectory(org.apache.lucene.store.FilterDirectory)

Example 4 with FilterFileSystem

use of org.apache.lucene.mockfile.FilterFileSystem in project lucene-solr by apache.

the class TestUtil method hasWindowsFS.

public static boolean hasWindowsFS(Directory dir) {
    dir = FilterDirectory.unwrap(dir);
    if (dir instanceof FSDirectory) {
        Path path = ((FSDirectory) dir).getDirectory();
        FileSystem fs = path.getFileSystem();
        while (fs instanceof FilterFileSystem) {
            FilterFileSystem ffs = (FilterFileSystem) fs;
            if (ffs.getParent() instanceof WindowsFS) {
                return true;
            }
            fs = ffs.getDelegate();
        }
    }
    return false;
}
Also used : Path(java.nio.file.Path) WindowsFS(org.apache.lucene.mockfile.WindowsFS) FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FSDirectory(org.apache.lucene.store.FSDirectory)

Example 5 with FilterFileSystem

use of org.apache.lucene.mockfile.FilterFileSystem in project lucene-solr by apache.

the class TestUtil method hasWindowsFS.

public static boolean hasWindowsFS(Path path) {
    FileSystem fs = path.getFileSystem();
    while (fs instanceof FilterFileSystem) {
        FilterFileSystem ffs = (FilterFileSystem) fs;
        if (ffs.getParent() instanceof WindowsFS) {
            return true;
        }
        fs = ffs.getDelegate();
    }
    return false;
}
Also used : WindowsFS(org.apache.lucene.mockfile.WindowsFS) FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem)

Aggregations

FileSystem (java.nio.file.FileSystem)5 FilterFileSystem (org.apache.lucene.mockfile.FilterFileSystem)5 VirusCheckingFS (org.apache.lucene.mockfile.VirusCheckingFS)3 FSDirectory (org.apache.lucene.store.FSDirectory)3 WindowsFS (org.apache.lucene.mockfile.WindowsFS)2 Directory (org.apache.lucene.store.Directory)2 FilterDirectory (org.apache.lucene.store.FilterDirectory)2 RAMDirectory (org.apache.lucene.store.RAMDirectory)2 Path (java.nio.file.Path)1