public class ModeFlags
extends java.lang.Object
implements java.lang.Cloneable
OpenFile| Modifier and Type | Field and Description |
|---|---|
static int |
ACCMODE
accmode flag, used to mask the read/write mode
|
static int |
APPEND
append flag, to seek to the end of the file
|
static int |
BINARY
binary flag, to ensure no encoding changes are made while writing (Windows only)
|
static int |
CREAT
create flag, to specify non-existing file should be created
|
static int |
EXCL
exclusive access flag, to require locking the target file
|
static int |
NONBLOCK
nonblock flag, to perform all operations non-blocking.
|
static java.nio.file.OpenOption |
NOSHARE_DELETE
try to access special mode flag, failover to default SHARE_DELETE otherwise
|
static int |
RDONLY
read-only flag (default value if no other flags set)
|
static int |
RDWR
read/write flag
|
static int |
SHARE_DELETE
delete shared file flag for windows, otherwise zero
|
static int |
TEXT
textmode flag, MRI has no equivalent but we use ModeFlags currently
to also capture what are oflags.
|
static int |
TMPFILE
tmpfile flag (Linux only)
|
static int |
TRUNC
truncate flag, to truncate the target file to zero length
|
static int |
WRONLY
write-only flag
|
| Constructor and Description |
|---|
ModeFlags()
Construct a new ModeFlags object with the default read-only flag.
|
ModeFlags(long flags)
Construct a new ModeFlags object with the specified flags
|
ModeFlags(java.lang.String flagString) |
| Modifier and Type | Method and Description |
|---|---|
static ModeFlags |
createModeFlags(int oflags) |
int |
getFcntlFileFlags()
Convert the flags in this object to a set of flags appropriate for the
fcntl.
|
int |
getFlags()
Return a value that, when passed to our constructor,
would create a copy of this instance.
|
static ModeFlags |
getModesFromChannel(java.nio.channels.Channel channel)
Deprecated.
|
static int |
getOFlagsFromString(Ruby runtime,
java.lang.String modesString) |
static int |
getOFlagsFromString(java.lang.String modesString) |
int |
getOpenFileFlags()
Convert the flags in this object to a set of flags appropriate for the
OpenFile structure and logic therein.
|
static int |
getOpenFileFlagsFor(int flags)
With the provided open flags parameter what fmode values should be
set (fmode for us is represented by OpenFile).
|
boolean |
isAppendable()
Whether the flags specify to append to existing files.
|
boolean |
isBinary()
Whether the flags specify "binary" mode for reads and writes.
|
boolean |
isCreate()
Whether the flags specify to create nonexisting files.
|
boolean |
isExclusive()
Whether the flags specify exclusive access.
|
boolean |
isReadable()
Whether the flags specify "readable", either read/write or read-only.
|
boolean |
isReadOnly()
Whether the flags specify"read only".
|
boolean |
isReadWrite()
Whether the flags specify "read/write".
|
boolean |
isShareDelete()
Whether the flags specify to allow deleting shared files (Windows FILE_SHARE_DELETE).
|
boolean |
isSubsetOf(ModeFlags superset)
Check whether the target set of flags is a superset of this one; used to
ensure that a file is not re-opened with more privileges than it already
had.
|
boolean |
isTemporary()
Whether the flags specify "unnamed temporary".
|
boolean |
isText()
Whether the flags specify "text" mode for reads and writes.
|
boolean |
isTruncate()
Whether the flags specify to truncate the target file.
|
boolean |
isWritable()
Whether the flags specify "writable", either read/write or write-only
|
boolean |
isWriteOnly()
Whether the flags specify "write only".
|
static int |
oflagsFrom(jnr.posix.POSIX posix,
java.nio.channels.Channel channel)
Build a set of mode flags using the specified channel's actual capabilities.
|
java.lang.String |
toJavaModeString()
Produce a Java IO mode string from the flags in this object.
|
java.nio.file.OpenOption[] |
toOpenOptions(boolean includeAppend,
boolean includeTruncate)
Produce an array of
OpenOption equivalent to these mode flags, including TRUNCATE_EXISTING only if
includeTruncate is set to true. |
java.lang.String |
toString() |
public static final int RDONLY
public static final int WRONLY
public static final int RDWR
public static final int CREAT
public static final int EXCL
public static final int TRUNC
public static final int APPEND
public static final int NONBLOCK
public static final int BINARY
public static final int TMPFILE
public static final int TEXT
public static final int SHARE_DELETE
public static final java.nio.file.OpenOption NOSHARE_DELETE
public static final int ACCMODE
public ModeFlags()
public ModeFlags(long flags)
throws InvalidValueException
flags - The flags to use for this objectInvalidValueException - If the modes are invalidpublic ModeFlags(java.lang.String flagString)
throws InvalidValueException
InvalidValueExceptionpublic static int getOFlagsFromString(java.lang.String modesString)
throws InvalidValueException
InvalidValueExceptionpublic static int getOFlagsFromString(Ruby runtime, java.lang.String modesString)
public static int oflagsFrom(jnr.posix.POSIX posix,
java.nio.channels.Channel channel)
channel - the channel to examine for capabilities@Deprecated public static ModeFlags getModesFromChannel(java.nio.channels.Channel channel)
channel - the channel to examine for capabilitiespublic java.lang.String toJavaModeString()
public java.nio.file.OpenOption[] toOpenOptions(boolean includeAppend,
boolean includeTruncate)
OpenOption equivalent to these mode flags, including TRUNCATE_EXISTING only if
includeTruncate is set to true.
Set includeTruncate to false if you intend to truncate the file separately.
The resulting array may be shared and should not be modified.includeTruncate - whether to include truncation in the optionsOpenOption that matches these mode flags.public final boolean isReadOnly()
public boolean isReadable()
public boolean isWriteOnly()
public boolean isReadWrite()
public boolean isBinary()
public boolean isText()
public boolean isTemporary()
public boolean isCreate()
public boolean isWritable()
public boolean isExclusive()
public boolean isAppendable()
public boolean isTruncate()
public boolean isShareDelete()
public boolean isSubsetOf(ModeFlags superset)
superset - The ModeFlags object which should be a superset of this onepublic java.lang.String toString()
toString in class java.lang.Objectpublic int getFlags()
public static int getOpenFileFlagsFor(int flags)
public int getOpenFileFlags()
public int getFcntlFileFlags()
public static ModeFlags createModeFlags(int oflags)
Copyright © 2001-2022 JRuby. All Rights Reserved.