IP : 18.226.94.15Hostname : server86.web-hosting.comKernel : Linux server86.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64Disable Function : None :) OS : Linux
PATH:
/
home/
./
./
../
../
lib64/
gssproxy/
../
python2.7/
site-packages/
../
posixfile.py/
/
"""Extended file operations available in POSIX.
f = posixfile.open(filename, [mode, [bufsize]]) will create a new posixfile object
f = posixfile.fileopen(fileobject) will create a posixfile object from a builtin file object
f.file() will return the original builtin file object
f.dup() will return a new file object based on a new filedescriptor
f.dup2(fd) will return a new file object based on the given filedescriptor
f.flags(mode) will turn on the associated flag (merge) mode can contain the following characters:
(character representing a flag) a append only flag c close on exec flag n no delay flag s synchronization flag (modifiers) ! turn flags 'off' instead of default 'on' = copy flags 'as is' instead of default 'merge' ? return a string in which the characters represent the flags that are set
note: - the '!' and '=' modifiers are mutually exclusive. - the '?' modifier will return the status of the flags after they have been changed by other characters in the mode string
f.lock(mode [, len [, start [, whence]]]) will (un)lock a region mode can contain the following characters:
(character representing type of lock) u unlock r read lock w write lock (modifiers) | wait until the lock can be granted ? return the first lock conflicting with the requested lock or 'None' if there is no conflict. The lock returned is in the format (mode, len, start, whence, pid) where mode is a character representing the type of lock ('r' or 'w')
note: - the '?' modifier prevents a region from being locked; it is query only """ import warnings warnings.warn("The posixfile module is deprecated; " "fcntl.lockf() provides better locking", DeprecationWarning, 2)
class _posixfile_: """File wrapper class that provides extra POSIX file routines."""
if which: if len(which) > 1: raise TypeError, 'Too many arguments' which = which[0] else: which = '?'
l_flags = 0 if 'n' in which: l_flags = l_flags | os.O_NDELAY if 'a' in which: l_flags = l_flags | os.O_APPEND if 's' in which: l_flags = l_flags | os.O_SYNC
file = self._file_
if '=' not in which: cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0) if '!' in which: l_flags = cur_fl & ~ l_flags else: l_flags = cur_fl | l_flags
if 'c' in which: arg = ('!' not in which) # 0 is don't, 1 is do close on exec l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)
if '?' in which: which = '' # Return current flags l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0) if os.O_APPEND & l_flags: which = which + 'a' if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1: which = which + 'c' if os.O_NDELAY & l_flags: which = which + 'n' if os.O_SYNC & l_flags: which = which + 's' return which
def lock(self, how, *args): import struct, fcntl
if 'w' in how: l_type = fcntl.F_WRLCK elif 'r' in how: l_type = fcntl.F_RDLCK elif 'u' in how: l_type = fcntl.F_UNLCK else: raise TypeError, 'no type of lock specified'
if '|' in how: cmd = fcntl.F_SETLKW elif '?' in how: cmd = fcntl.F_GETLK else: cmd = fcntl.F_SETLK