Package jnr.posix

Examples of jnr.posix.FileStat


        if (ch instanceof NativeSelectableChannel) chNative = (NativeSelectableChannel)ch;
        else chNative = null;

        if (chNative != null) {
            // we have an ENXIO channel, but need to know if it's a regular file to skip selection
            FileStat stat = posix.fstat(chNative.getFD());
            if (stat.isFile()) {
                chSelect = null;
                isNativeFile = true;
            }
        }
    }
View Full Code Here


    private void SET_TEXT_MODE() {
        // FIXME: this only does something if we have O_TEXT at open(2) level
    }

    public int remainSize() {
        FileStat st;
        int siz = READ_DATA_PENDING_COUNT();
        long pos;

        // MRI does all this presumably to read more of the file right away, but
        // I believe the logic that uses this is ok with just pending read plus buf size.
View Full Code Here

        return 0;
    }

    public long size(ChannelFD fd) {
        if (fd.chNative != null) { // native fd, use fstat
            FileStat stat = posix.allocateStat();
            int ret = posix.fstat(fd.chNative.getFD(), stat);
            if (ret == -1) {
                errno = Errno.valueOf(posix.errno());
                return -1;
            }
            return stat.st_size();
        } else if (fd.chSeek != null) { // if it is seekable, get size directly
            try {
                return fd.chSeek.size();
            } catch (IOException ioe) {
                errno = Helpers.errnoFromException(ioe);
View Full Code Here

    public FileDescriptorIO(Ruby runtime, IRubyObject fd) {
        super(runtime, runtime.getModule("FFI").getClass(CLASS_NAME));
        MakeOpenFile();
        ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR);
        int fileno = RubyNumeric.fix2int(fd);
        FileStat stat = runtime.getPosix().fstat(fileno);
        ByteChannel channel;

        if (stat.isSocket()) {
            channel = new jnr.enxio.channels.NativeSocketChannel(fileno);
        } else if (stat.isBlockDev() || stat.isCharDev()) {
            channel = new jnr.enxio.channels.NativeDeviceChannel(fileno);
        } else {
            channel = new FileDescriptorByteChannel(runtime, fileno);
        }
View Full Code Here

TOP

Related Classes of jnr.posix.FileStat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.