/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @return a new ChannelDescriptor based on the specified parameters * @throws java.io.FileNotFoundException if the target file could not be found * and the create flag was not specified * @throws org.jruby.util.io.DirectoryAsFileException if the target file is * a directory being opened as a file * @throws org.jruby.util.io.FileExistsException if the target file should * be created anew, but already exists * @throws java.io.IOException if there is an exception during IO */ public static ChannelDescriptor open(String cwd, String path, ModeFlags flags) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, null, null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param classLoader a ClassLoader to use for classpath: resources * @return a new ChannelDescriptor based on the specified parameters * @throws java.io.FileNotFoundException if the target file could not be found * and the create flag was not specified * @throws org.jruby.util.io.DirectoryAsFileException if the target file is * a directory being opened as a file * @throws org.jruby.util.io.FileExistsException if the target file should * be created anew, but already exists * @throws java.io.IOException if there is an exception during IO */ public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, ClassLoader classLoader) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, null, classLoader); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param classLoader a ClassLoader to use for classpath: resources * @return a new ChannelDescriptor based on the specified parameters * @throws java.io.FileNotFoundException if the target file could not be found * and the create flag was not specified * @throws org.jruby.util.io.DirectoryAsFileException if the target file is * a directory being opened as a file * @throws org.jruby.util.io.FileExistsException if the target file should * be created anew, but already exists * @throws java.io.IOException if there is an exception during IO */ public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, ClassLoader classLoader) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, null, classLoader); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @return a new ChannelDescriptor based on the specified parameters * @throws java.io.FileNotFoundException if the target file could not be found * and the create flag was not specified * @throws org.jruby.util.io.DirectoryAsFileException if the target file is * a directory being opened as a file * @throws org.jruby.util.io.FileExistsException if the target file should * be created anew, but already exists * @throws java.io.IOException if there is an exception during IO */ public static ChannelDescriptor open(String cwd, String path, ModeFlags flags) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, null, null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param perm the file permissions to use when creating a new file (currently * unobserved) * @param posix a POSIX api implementation, used for setting permissions; if null, permissions are ignored * @return a new ChannelDescriptor based on the specified parameters * @throws java.io.FileNotFoundException if the target file could not be found * and the create flag was not specified * @throws org.jruby.util.io.DirectoryAsFileException if the target file is * a directory being opened as a file * @throws org.jruby.util.io.FileExistsException if the target file should * be created anew, but already exists * @throws java.io.IOException if there is an exception during IO */ public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, int perm, POSIX posix) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, perm, posix, null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param perm the file permissions to use when creating a new file (currently * unobserved) * @param posix a POSIX api implementation, used for setting permissions; if null, permissions are ignored * @return a new ChannelDescriptor based on the specified parameters * @throws java.io.FileNotFoundException if the target file could not be found * and the create flag was not specified * @throws org.jruby.util.io.DirectoryAsFileException if the target file is * a directory being opened as a file * @throws org.jruby.util.io.FileExistsException if the target file should * be created anew, but already exists * @throws java.io.IOException if there is an exception during IO */ public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, int perm, POSIX posix) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, perm, posix, null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param perm the file permissions to use when creating a new file (currently * unobserved) * @param posix a POSIX api implementation, used for setting permissions; if null, permissions are ignored * @return a new ChannelDescriptor based on the specified parameters */ @Deprecated public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, int perm, POSIX posix) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, perm, posix, null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param perm the file permissions to use when creating a new file (currently * unobserved) * @param posix a POSIX api implementation, used for setting permissions; if null, permissions are ignored * @return a new ChannelDescriptor based on the specified parameters */ @Deprecated public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, int perm, POSIX posix) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, perm, posix, null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @return a new ChannelDescriptor based on the specified parameters */ @Deprecated public static ChannelDescriptor open(String cwd, String path, ModeFlags flags) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, POSIXFactory.getPOSIX(), null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @return a new ChannelDescriptor based on the specified parameters */ @Deprecated public static ChannelDescriptor open(String cwd, String path, ModeFlags flags) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, POSIXFactory.getPOSIX(), null); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param classLoader a ClassLoader to use for classpath: resources * @return a new ChannelDescriptor based on the specified parameters */ @Deprecated public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, ClassLoader classLoader) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, POSIXFactory.getPOSIX(), classLoader); }
/** * Open a new descriptor using the given working directory, file path, * mode flags, and file permission. This is equivalent to the open(2) * POSIX function. See org.jruby.util.io.ChannelDescriptor.open(String, String, ModeFlags, int, POSIX) * for the version that also sets file permissions. * * @param cwd the "current working directory" to use when opening the file * @param path the file path to open * @param flags the mode flags to use for opening the file * @param classLoader a ClassLoader to use for classpath: resources * @return a new ChannelDescriptor based on the specified parameters */ @Deprecated public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, ClassLoader classLoader) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException { return open(cwd, path, flags, 0, POSIXFactory.getPOSIX(), classLoader); }
@Deprecated // no longer used public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException { try { ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader()); Stream stream = fdopen(runtime, descriptor, modes); return stream; } catch (ResourceException resourceException) { throw resourceException.newRaiseException(runtime); } }
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException { ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader()); Stream stream = fdopen(runtime, descriptor, modes); return stream; }
@Deprecated // no longer used public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException { try { ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader()); Stream stream = fdopen(runtime, descriptor, modes); return stream; } catch (ResourceException resourceException) { throw resourceException.newRaiseException(runtime); } }
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException { ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader()); Stream stream = fdopen(runtime, descriptor, modes); return stream; }
try { ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes.getModeFlags(), perms, runtime.getPosix(), runtime.getJRubyClassLoader());
private ChannelDescriptor sysopen(String path, ModeFlags modes, int perm) { try { ChannelDescriptor descriptor = ChannelDescriptor.open( getRuntime().getCurrentDirectory(), path, modes, perm, getRuntime().getPosix(), getRuntime().getJRubyClassLoader()); // TODO: check if too many open files, GC and try again return descriptor; } catch (PermissionDeniedException pde) { // PDException can be thrown only when creating the file and // permission is denied. See JavaDoc of PermissionDeniedException. throw getRuntime().newErrnoEACCESError(path); } catch (FileNotFoundException fnfe) { // FNFException can be thrown in both cases, when the file // is not found, or when permission is denied. if (Ruby.isSecurityRestricted() || new File(path).exists()) { throw getRuntime().newErrnoEACCESError(path); } throw getRuntime().newErrnoENOENTError(path); } catch (DirectoryAsFileException dafe) { throw getRuntime().newErrnoEISDirError(); } catch (FileExistsException fee) { throw getRuntime().newErrnoEEXISTError(path); } catch (IOException ioe) { throw getRuntime().newIOErrorFromException(ioe); } }
private ChannelDescriptor sysopen(String path, ModeFlags modes, int perm) { try { ChannelDescriptor descriptor = ChannelDescriptor.open( getRuntime().getCurrentDirectory(), path, modes, perm, getRuntime().getPosix(), getRuntime().getJRubyClassLoader()); // TODO: check if too many open files, GC and try again return descriptor; } catch (PermissionDeniedException pde) { // PDException can be thrown only when creating the file and // permission is denied. See JavaDoc of PermissionDeniedException. throw getRuntime().newErrnoEACCESError(path); } catch (FileNotFoundException fnfe) { // FNFException can be thrown in both cases, when the file // is not found, or when permission is denied. if (Ruby.isSecurityRestricted() || new File(path).exists()) { throw getRuntime().newErrnoEACCESError(path); } throw getRuntime().newErrnoENOENTError(path); } catch (DirectoryAsFileException dafe) { throw getRuntime().newErrnoEISDirError(); } catch (FileExistsException fee) { throw getRuntime().newErrnoEEXISTError(path); } catch (IOException ioe) { throw getRuntime().newIOErrorFromException(ioe); } }
try { ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes.getModeFlags(), perms, runtime.getPosix(), runtime.getJRubyClassLoader());