Search in sources :

Example 6 with FileAttribute

use of java.nio.file.attribute.FileAttribute in project j2objc by google.

the class FilesTest method test_createDirectories$Path$Attr_NPE.

@Test
public void test_createDirectories$Path$Attr_NPE() throws IOException {
    Path dirPath = filesSetup.getPathInTestDir("dir1/dir2/dir3");
    Set<PosixFilePermission> perm = PosixFilePermissions.fromString("rwx------");
    FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perm);
    try {
        Files.createDirectories(null, attr);
        fail();
    } catch (NullPointerException expected) {
    }
    try {
        Files.createDirectories(dirPath, (FileAttribute<?>[]) null);
        fail();
    } catch (NullPointerException expected) {
    }
}
Also used : Path(java.nio.file.Path) HashSet(java.util.HashSet) Set(java.util.Set) PosixFilePermission(java.nio.file.attribute.PosixFilePermission) FileAttribute(java.nio.file.attribute.FileAttribute) Test(org.junit.Test)

Example 7 with FileAttribute

use of java.nio.file.attribute.FileAttribute in project tomcat by apache.

the class TestFileResourceSet method before.

@BeforeClass
public static void before() throws IOException {
    tempDir = Files.createTempDirectory("test", new FileAttribute[0]);
    dir2 = new File(tempDir.toFile(), "dir2");
    TomcatBaseTest.recursiveCopy(new File("test/webresources/dir2").toPath(), dir2.toPath());
}
Also used : File(java.io.File) FileAttribute(java.nio.file.attribute.FileAttribute) BeforeClass(org.junit.BeforeClass)

Example 8 with FileAttribute

use of java.nio.file.attribute.FileAttribute in project tomcat by apache.

the class TestDirResourceSetInternal method before.

@BeforeClass
public static void before() throws IOException {
    tempDir = Files.createTempDirectory("test", new FileAttribute[0]);
    dir1 = new File(tempDir.toFile(), "dir1");
    TomcatBaseTest.recursiveCopy(new File("test/webresources/dir1").toPath(), dir1.toPath());
}
Also used : File(java.io.File) FileAttribute(java.nio.file.attribute.FileAttribute) BeforeClass(org.junit.BeforeClass)

Example 9 with FileAttribute

use of java.nio.file.attribute.FileAttribute in project tomcat by apache.

the class TestFileResourceSetReadOnly method before.

@BeforeClass
public static void before() throws IOException {
    tempDir = Files.createTempDirectory("test", new FileAttribute[0]);
    dir2 = new File(tempDir.toFile(), "dir2");
    TomcatBaseTest.recursiveCopy(new File("test/webresources/dir2").toPath(), dir2.toPath());
}
Also used : File(java.io.File) FileAttribute(java.nio.file.attribute.FileAttribute) BeforeClass(org.junit.BeforeClass)

Example 10 with FileAttribute

use of java.nio.file.attribute.FileAttribute in project mycore by MyCoRe-Org.

the class MCRDirectoryStream method newByteChannel.

@Override
public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
    checkClosed();
    MCRPath mcrPath = checkRelativePath(path);
    if (mcrPath.isAbsolute()) {
        return mcrPath.getFileSystem().provider().newByteChannel(mcrPath, options, attrs);
    }
    Set<? extends OpenOption> fileOpenOptions = options.stream().filter(option -> !(option == StandardOpenOption.CREATE || option == StandardOpenOption.CREATE_NEW)).collect(Collectors.toSet());
    boolean create = options.contains(StandardOpenOption.CREATE);
    boolean createNew = options.contains(StandardOpenOption.CREATE_NEW);
    if (create || createNew) {
        for (OpenOption option : fileOpenOptions) {
            // check before we create any file instance
            MCRFile.checkOpenOption(option);
        }
    }
    MCRFileSystemProvider provider = (MCRFileSystemProvider) mcrPath.getFileSystem().provider();
    MCRFileSystemUtils.getMCRFile(dir, mcrPath, create, createNew);
    return provider.newByteChannel(this.path.resolve(mcrPath), fileOpenOptions, attrs);
}
Also used : NoSuchFileException(java.nio.file.NoSuchFileException) ClosedDirectoryStreamException(java.nio.file.ClosedDirectoryStreamException) MCRFileAttributes(org.mycore.datamodel.niofs.MCRFileAttributes) LinkOption(java.nio.file.LinkOption) InvalidPathException(java.nio.file.InvalidPathException) MCRDirectory(org.mycore.datamodel.ifs.MCRDirectory) MCRMD5AttributeView(org.mycore.datamodel.niofs.MCRMD5AttributeView) SecureDirectoryStream(java.nio.file.SecureDirectoryStream) BasicFileAttributeView(java.nio.file.attribute.BasicFileAttributeView) NoSuchElementException(java.util.NoSuchElementException) Path(java.nio.file.Path) MCRFile(org.mycore.datamodel.ifs.MCRFile) Iterator(java.util.Iterator) Files(java.nio.file.Files) OpenOption(java.nio.file.OpenOption) MCRPath(org.mycore.datamodel.niofs.MCRPath) FileAttributeView(java.nio.file.attribute.FileAttributeView) MCRPersistenceException(org.mycore.common.MCRPersistenceException) StandardOpenOption(java.nio.file.StandardOpenOption) Set(java.util.Set) IOException(java.io.IOException) FileAttribute(java.nio.file.attribute.FileAttribute) Collectors(java.util.stream.Collectors) DirectoryIteratorException(java.nio.file.DirectoryIteratorException) Objects(java.util.Objects) SeekableByteChannel(java.nio.channels.SeekableByteChannel) Logger(org.apache.logging.log4j.Logger) MCRFilesystemNode(org.mycore.datamodel.ifs.MCRFilesystemNode) AtomicMoveNotSupportedException(java.nio.file.AtomicMoveNotSupportedException) Optional(java.util.Optional) LogManager(org.apache.logging.log4j.LogManager) OpenOption(java.nio.file.OpenOption) StandardOpenOption(java.nio.file.StandardOpenOption) MCRPath(org.mycore.datamodel.niofs.MCRPath)

Aggregations

FileAttribute (java.nio.file.attribute.FileAttribute)20 File (java.io.File)15 Path (java.nio.file.Path)7 HashSet (java.util.HashSet)7 BeforeClass (org.junit.BeforeClass)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 IOException (java.io.IOException)4 Set (java.util.Set)4 Configuration (org.apache.hadoop.conf.Configuration)4 Path (org.apache.hadoop.fs.Path)4 LongWritable (org.apache.hadoop.io.LongWritable)4 InputSplit (org.apache.hadoop.mapreduce.InputSplit)4 Job (org.apache.hadoop.mapreduce.Job)4 JobContext (org.apache.hadoop.mapreduce.JobContext)4 TaskAttemptContext (org.apache.hadoop.mapreduce.TaskAttemptContext)4 TaskAttemptID (org.apache.hadoop.mapreduce.TaskAttemptID)4 JobContextImpl (org.apache.hadoop.mapreduce.task.JobContextImpl)4 TaskAttemptContextImpl (org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl)4 Node (org.apache.jena.graph.Node)4