Package org.jruby.util.io
Class PosixShim
java.lang.Object
org.jruby.util.io.PosixShim
Representations of as many native posix functions as possible applied to an NIO channel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static intThe last umask we setprivate static final ObjectAn object to synchronize calls to umaskThe recommended error message, if any.private final ThreadLocal<jnr.constants.platform.Errno>The last Throwable exception raised by a call.private static final intstatic final intstatic final intstatic final intstatic final intprivate static final intprivate final jnr.posix.POSIXThe POSIX instance to use for native callsprivate final RubyThe current runtimestatic final intstatic final intstatic final intstatic final PosixShim.WaitMacros -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intcheckSharedExclusive(ChannelFD fd, int lockMode) private voidclear()intintintintfcntlGetFD(int fd) intfcntlSetFD(int fd, int flags) intintjnr.constants.platform.ErrnogetErrno()The appropriate errno value for the last thrown error, if any.private intprivate static intlockFailedReturn(int lockMode) private static booleanlockStateChanges(FileLock lock, int lockMode) longopen(String cwd, String path, ModeFlags flags, int perm, ClassLoader classLoader) Deprecated.Channel[]pipe()intintsetCloexec(int fd, boolean cloexec) voidsetErrno(jnr.constants.platform.Errno errno) longprivate intstatic intumask(jnr.posix.POSIX posix) Joy of POSIX, only way to get the umask is to set the umask, then set it back.static intumask(jnr.posix.POSIX posix, int newMask) private intint
-
Field Details
-
LOCK_SH
public static final int LOCK_SH- See Also:
-
LOCK_EX
public static final int LOCK_EX- See Also:
-
LOCK_NB
public static final int LOCK_NB- See Also:
-
LOCK_UN
public static final int LOCK_UN- See Also:
-
SEEK_SET
public static final int SEEK_SET- See Also:
-
SEEK_CUR
public static final int SEEK_CUR- See Also:
-
SEEK_END
public static final int SEEK_END- See Also:
-
NATIVE_EOF
private static final int NATIVE_EOF- See Also:
-
JAVA_EOF
private static final int JAVA_EOF- See Also:
-
WAIT_MACROS
-
error
The last Throwable exception raised by a call. -
errno
-
errmsg
The recommended error message, if any. -
posix
private final jnr.posix.POSIX posixThe POSIX instance to use for native calls -
runtime
The current runtime -
_umaskLock
An object to synchronize calls to umask -
_cachedUmask
private static int _cachedUmaskThe last umask we set
-
-
Constructor Details
-
PosixShim
-
-
Method Details
-
lseek
-
write
-
read
-
flock
-
dup2
-
close
-
close
-
pipe
-
getErrno
public jnr.constants.platform.Errno getErrno()The appropriate errno value for the last thrown error, if any. -
setErrno
public void setErrno(jnr.constants.platform.Errno errno) -
setCloexec
public int setCloexec(int fd, boolean cloexec) -
fcntlSetFD
public int fcntlSetFD(int fd, int flags) -
fcntlGetFD
public int fcntlGetFD(int fd) -
open
-
open
-
open
@Deprecated public Channel open(String cwd, String path, ModeFlags flags, int perm, ClassLoader classLoader) Deprecated. -
umask
public static int umask(jnr.posix.POSIX posix) Joy of POSIX, only way to get the umask is to set the umask, then set it back. That's unsafe in a threaded program. We minimize but may not totally remove this race by caching the obtained or previously set (see umask() above) umask and using that as the initial set value which, cross fingers, is a no-op. The cache access is then synchronized. TODO: Better? -
umask
public static int umask(jnr.posix.POSIX posix, int newMask) -
ftruncate
-
size
-
clear
private void clear() -
lockFailedReturn
private static int lockFailedReturn(int lockMode) -
lockStateChanges
-
unlock
- Throws:
IOException
-
lock
- Throws:
IOException
-
tryLock
- Throws:
IOException
-