Java 类java.nio.file.ReadOnlyFileSystemException 实例源码

项目:filesystem    文件:AbstractPath.java   
@Override
public Iterator<Path> iterator()
{
    return new Iterator<Path>()
    {
        private int i = 0;

        @Override
        public boolean hasNext()
        {
            return (i < getNameCount());
        }

        @Override
        public Path next()
        {
            if( i < getNameCount() ) {
                Path result = getName( i );
                i++;
                return result;
            }
            else {
                throw new NoSuchElementException();
            }
        }

        @Override
        public void remove()
        {
            throw new ReadOnlyFileSystemException();
        }
    };
}
项目:archive-fs    文件:TarPath.java   
@Override
public Iterator<Path> iterator() {
    return new Iterator<Path>() {
        private int i = 0;

        @Override
        public boolean hasNext() {
            return i < getNameCount();
        }

        @Override
        public Path next() {
            if (i < getNameCount()) {
                Path result = getName(i);
                i++;
                return result;
            } else {
                throw new NoSuchElementException();
            }
        }

        @Override
        public void remove() {
            throw new ReadOnlyFileSystemException();
        }
    };
}
项目:eightyfs    文件:GuestFileAttributeView.java   
@Override
public void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime) throws IOException {
    if ( readonly ) {
        throw new ReadOnlyFileSystemException();
    }
    basicHost().setTimes( lastModifiedTime, lastAccessTime, createTime );
}
项目:memoryfs    文件:MemoryFileAttributesView.java   
@Override
public void setTimes( @Nullable FileTime lastModifiedTime, @Nullable FileTime lastAccessTime, @Nullable FileTime createTime ) throws IOException {
    if ( readonly ) {
        throw new ReadOnlyFileSystemException();
    }

    attis.setTimes( Optional.ofNullable( lastModifiedTime ), Optional.ofNullable( lastAccessTime ), Optional.ofNullable( createTime ));
}
项目:openjdk-jdk10    文件:JrtFileSystem.java   
static ReadOnlyFileSystemException readOnly() {
    return new ReadOnlyFileSystemException();
}
项目:openjdk9    文件:JrtFileSystem.java   
static ReadOnlyFileSystemException readOnly() {
    return new ReadOnlyFileSystemException();
}
项目:jigsaw-jrtfs    文件:JrtFileSystem.java   
private ReadOnlyFileSystemException readOnly() {
    return new ReadOnlyFileSystemException();
}
项目:eightyfs    文件:ProviderChannel.java   
@SuppressWarnings({ "PMD.NPathComplexity" })
public static <T extends SeekableByteChannel> FileChannel newChannel( EightyPath pathArg, Set<? extends OpenOption> options, BiFunction<EightyPath, Set<OpenOption>, T> create ) throws IOException {
    final EightyFileSystem eightyFileSystem = pathArg._getFileSystem();

    EightyPath path = toRealPath( pathArg );

    Set<OpenOption> impliedOptions = new HashSet<>( options );

    if( impliedOptions.isEmpty() ) {
        impliedOptions.add( READ );
    }

    if ( impliedOptions.contains( APPEND )) {
        impliedOptions.add( WRITE );
    }

    newByteChannelParentCheck( path );

    throwIfPathIsNotAccessible( path );

    boolean creating = byteChannelCheckExistence( options, path );

    if( options.contains( APPEND ) && options.contains( READ ) ) {
        throw new IllegalArgumentException( "APPEND + READ not allowed" );
    }

    if( options.contains( APPEND ) && options.contains( TRUNCATE_EXISTING ) ) {
        throw new IllegalArgumentException( "APPEND + TRUNCATE_EXISTING not allowed" );
    }

    if( Files.isDirectory( path ) ) {
        throw new FileSystemException( path.toString() + " is a directory" );
    }

    if( impliedOptions.contains( WRITE ) ) {
        if( eightyFileSystem.isReadOnly() ) {
            throw new ReadOnlyFileSystemException();
        }

        if ( !creating && !Files.isWritable( path )) {
            throw new AccessDeniedException( "file not writable" );
        }
    }

    if ( creating ) {
        eightyFileSystem.get80().newContent( path );
    }

    T unwachedChannel = eightyFileSystem.addClosable( create.apply( path, impliedOptions ) );

    FileChannel ret = new WatchableByteChannel( unwachedChannel, () -> eightyFileSystem.signal( path, StandardWatchEventKinds.ENTRY_MODIFY ));
    if( creating ) {
        // e.g. means has a a parent
        FileTime now = FileTime.from( Clock.systemUTC().instant() );
        Files.getFileAttributeView( childGetParent( path ), BasicFileAttributeView.class ).setTimes( now, now, null );

        path._getFileSystem().signal( path, StandardWatchEventKinds.ENTRY_CREATE );
    } else if ( impliedOptions.contains( WRITE )) {
        path._getFileSystem().signal( path, StandardWatchEventKinds.ENTRY_MODIFY );
    }
    return ret;

}
项目:jsr203-hadoop    文件:HadoopFileSystem.java   
private void checkWritable() throws IOException {
    if (readOnly)
        throw new ReadOnlyFileSystemException();
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testCanNotWriteToReadonlyFile() throws IOException {
    Files.write( getFile(), CONTENT );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testCanNotAppendToReadonlyFile() throws IOException {
    Files.write( getFile(), CONTENT, APPEND );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testSetAttributeToReadonlyThrows() throws IOException {
    Files.setLastModifiedTime( getFile(), FileTime.fromMillis( 500 ) );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testWriteNewFileToReadonly() throws IOException {
    Files.write( getNonEmptyDir().resolve( "newfile" ), CONTENT );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testMoveFileInReadonly() throws IOException {
    Files.move( getFile(), getNonEmptyDir().resolve( "newfile" ) );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testCopyFileInReadonly() throws IOException {
    Files.copy( getFile(), getNonEmptyDir().resolve( "newfile" ) );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testDeleteFileInReadonly() throws IOException {
    Files.delete( getFile() );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testDeleteDirInReadonly() throws IOException {
    Files.delete( getEmptyDir() );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class } )
public void testCreateHardLinkInReadonly() throws IOException {
    Files.createLink( getNonEmptyDir().resolve( "newLink" ), getFile() );
}
项目:niotest    文件:Tests21Readonly.java   
@Test( expected = ReadOnlyFileSystemException.class )
@Category( { Readonly.class, SymLink.class } )
public void testCreateSymLinkInReadonly() throws IOException {
    Files.createSymbolicLink( getNonEmptyDir().resolve( "newLink" ), getFile() );
}