Examples of FileStat


Examples of jnr.posix.FileStat

    // rb_file_size but not using stat
    @JRubyMethod
    public IRubyObject size(ThreadContext context) {
        Ruby runtime = context.runtime;
        OpenFile fptr;
        FileStat st;
        long size;

        fptr = getOpenFileChecked();
        if ((fptr.getMode() & OpenFile.WRITABLE) != 0) {
            flushRaw(context, false);
View Full Code Here

Examples of jnr.posix.FileStat

                    new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK));
        }

        private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException {
            File file = new File(filename);
            FileStat stat = runtime.getPosix().stat(filename);

            if (!extension.equals("")) {
                file.renameTo(new File(filename + extension));
            } else {
                file.delete();
            }

            createNewFile(file);

            runtime.getPosix().chmod(filename, stat.mode());
            runtime.getPosix().chown(filename, stat.uid(), stat.gid());
            runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(),
                    new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK));
        }
View Full Code Here

Examples of jnr.posix.FileStat

            throw runtime.newErrnoEACCESError(path);
        }

        // Since we transcode we depend on posix to lookup stat stuff since
        // java.io.File does not seem to cut it.  A failed stat will throw ENOENT.
        FileStat stat = runtime.getPosix().stat(directory.toString());

        // is not directory
        if (!stat.isDirectory()) throw runtime.newErrnoENOTDIRError(path);

        return directory;
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return file.isDirectory();
    }

    @Override
    public boolean isSymLink() {
        FileStat stat = posix.allocateStat();

        return posix.lstat(file.getAbsolutePath(), stat) < 0 ?
                false : stat.isSymlink();
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return list;
    }

    @Override
    public FileStat stat() {
        FileStat stat = posix.allocateStat();

        return posix.stat(file.getAbsolutePath(), stat) < 0 ? null : stat;
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return posix.stat(file.getAbsolutePath(), stat) < 0 ? null : stat;
    }

    @Override
    public FileStat lstat() {
        FileStat stat = posix.allocateStat();

        return posix.lstat(file.getAbsolutePath(), stat) < 0 ? null : stat;
    }
View Full Code Here

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

Examples of jnr.posix.FileStat

    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

Examples of jnr.posix.FileStat

        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

Examples of jnr.posix.FileStat

    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
Copyright © 2018 www.massapi.com. 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.