use of java.nio.file.FileSystem in project gerrit by GerritCodeReview.
the class GerritLauncher method getZipFileSystem.
public static synchronized FileSystem getZipFileSystem(Path zip) throws IOException {
// FileSystems canonicalizes the path, so we should too.
zip = zip.toRealPath();
FileSystem zipFs = zipFileSystems.get(zip);
if (zipFs == null) {
zipFs = newZipFileSystem(zip);
zipFileSystems.put(zip, zipFs);
}
return zipFs;
}
use of java.nio.file.FileSystem 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;
}
use of java.nio.file.FileSystem 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();
}
}
}
use of java.nio.file.FileSystem 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;
}
use of java.nio.file.FileSystem in project lucene-solr by apache.
the class TestIOUtils method testSSD.
public void testSSD() throws Exception {
assumeFalse("windows is not supported", Constants.WINDOWS);
Path dir = createTempDir();
dir = FilterPath.unwrap(dir).toRealPath();
// fake ssd
FileStore root = new MockFileStore(dir.toString() + " (/dev/zzz1)", "btrfs", "/dev/zzz1");
// make a fake /dev/zzz1 for it
Path devdir = dir.resolve("dev");
Files.createDirectories(devdir);
Files.createFile(devdir.resolve("zzz1"));
// make a fake /sys/block/zzz/queue/rotational file for it
Path sysdir = dir.resolve("sys").resolve("block").resolve("zzz").resolve("queue");
Files.createDirectories(sysdir);
try (OutputStream o = Files.newOutputStream(sysdir.resolve("rotational"))) {
o.write("0\n".getBytes(StandardCharsets.US_ASCII));
}
Map<String, FileStore> mappings = Collections.singletonMap(dir.toString(), root);
FileSystem mockLinux = new MockLinuxFileSystemProvider(dir.getFileSystem(), mappings, dir).getFileSystem(null);
Path mockPath = mockLinux.getPath(dir.toString());
assertFalse(IOUtils.spinsLinux(mockPath));
}
Aggregations