Package jnr.posix

Examples of jnr.posix.FileStat


                    if (extendedFilename != null) return extendedFilename;
                    continue;
                }

                try {
                    FileStat stat = posix.stat(filename);
                    if (!executableOnly || (!stat.isDirectory() && stat.isExecutable())) return filename;
                } catch (Throwable t) {}
            }
        }
       
        return null;
View Full Code Here


                   
                    if (extendedFilename != null) return extendedFilename;
                    continue;
                }
               
                FileStat stat = posix.allocateStat();
                int value = posix.libc().stat(filename, stat);
                if (value >= 0) {
                    if (!executableOnly) return filename;
                   
                    if (!stat.isDirectory() && stat.isExecutable()) {
                        return filename;
                    }
                }
            }
        }
View Full Code Here

                    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

        if ((openFile.getMode() & OpenFile.WRITABLE) != 0) {
            flush();
        }

        try {
            FileStat stat = runtime.getPosix().fstat(
                    getOpenFileChecked().getMainStreamSafe().getDescriptor().getFileDescriptor());
            if (stat == null) {
                throw runtime.newErrnoEACCESError(path);
            }

            return runtime.newFixnum(stat.st_size());
        } catch (BadDescriptorException e) {
            throw runtime.newErrnoEBADFError();
        }
    }
View Full Code Here

            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

        return fileTestModule;
    }

    @JRubyMethod(name = "blockdev?", required = 1, module = true)
    public static IRubyObject blockdev_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isBlockDev());
    }
View Full Code Here

        return recv.getRuntime().newBoolean(stat != null && stat.isBlockDev());
    }

    @JRubyMethod(name = "chardev?", required = 1, module = true)
    public static IRubyObject chardev_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isCharDev());
    }
View Full Code Here

        return context.runtime.newBoolean(fileResource(context, filename).isDirectory());
    }

    @JRubyMethod(name = "executable?", required = 1, module = true)
    public static IRubyObject executable_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isExecutable());
    }
View Full Code Here

        return recv.getRuntime().newBoolean(stat != null && stat.isExecutable());
    }

    @JRubyMethod(name = "executable_real?", required = 1, module = true)
    public static IRubyObject executable_real_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isExecutableReal());
    }
View Full Code Here

        return file_p(recv.getRuntime().getCurrentContext(), recv, filename);
    }

    @JRubyMethod(name = "file?", required = 1, module = true)
    public static RubyBoolean file_p(ThreadContext context, IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return context.runtime.newBoolean(stat != null && stat.isFile());
    }
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.