public UnixSshSeekableByteChannel()

in src/main/java/com/pastdev/jsch/nio/file/UnixSshSeekableByteChannel.java [28:70]


    public UnixSshSeekableByteChannel( UnixSshPath path, Set<? extends OpenOption> openOptions, FileAttribute<?>... createFileAttributes ) throws IOException {
        this.path = path.toAbsolutePath();
        this.append = openOptions.contains( StandardOpenOption.APPEND );
        this.readable = openOptions.isEmpty() || openOptions.contains( StandardOpenOption.READ );
        this.writeable = openOptions.contains( StandardOpenOption.WRITE );

        this.provider = path.getFileSystem().provider();

        PosixFileAttributes attributes = null;
        try {
            provider.checkAccess( path );
            attributes = provider.readAttributes( path, PosixFileAttributes.class );
        }
        catch ( NoSuchFileException e ) {
        }

        boolean create = false;
        if ( openOptions.contains( StandardOpenOption.CREATE_NEW ) ) {
            if ( attributes != null ) {
                throw new FileAlreadyExistsException( path.toString() );
            }
            create = true;
        }
        else if ( openOptions.contains( StandardOpenOption.CREATE ) ) {
            if ( attributes == null ) {
                create = true;
            }
        }
        else if ( attributes == null ) {
            throw new NoSuchFileException( "file not found and no CREATE/CREATE_NEW specified for "
                    + path.toString() );
        }

        if ( create ) {
            attributes = provider.createFile( path, createFileAttributes );
        }

        size = attributes.size();

        open = true;

        // maybe wanna lock file a la 'flock'
    }