本文整理汇总了Python中os.O_LARGEFILE属性的典型用法代码示例。如果您正苦于以下问题:Python os.O_LARGEFILE属性的具体用法?Python os.O_LARGEFILE怎么用?Python os.O_LARGEFILE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类os
的用法示例。
在下文中一共展示了os.O_LARGEFILE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mode2flags
# 需要导入模块: import os [as 别名]
# 或者: from os import O_LARGEFILE [as 别名]
def mode2flags(mode):
"""mode2flags(modestring)
Converts a file mode in string form (e.g. "w+") to an integer flag value
suitable for os.open(). """
flags = os.O_LARGEFILE # XXX only when Python compiled with large file support
if mode == "a":
flags = flags | os.O_APPEND | os.O_WRONLY
elif mode == "a+":
flags = flags | os.O_APPEND | os.O_RDWR | os.O_CREAT
elif mode == "w":
flags = flags | os.O_WRONLY | os.O_CREAT
elif mode == "w+":
flags = flags | os.O_RDWR | os.O_CREAT
elif mode == "r":
pass # O_RDONLY is zero already
elif mode == "r+":
flags = flags | os.O_RDWR
return flags
# precompute the O_ flag list, and stash it in the os module
示例2: get_lockdata
# 需要导入模块: import os [as 别名]
# 或者: from os import O_LARGEFILE [as 别名]
def get_lockdata():
if sys.platform.startswith('atheos'):
start_len = "qq"
else:
try:
os.O_LARGEFILE
except AttributeError:
start_len = "ll"
else:
start_len = "qq"
if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd', 'bsdos'))
or sys.platform == 'darwin'):
if struct.calcsize('l') == 8:
off_t = 'l'
pid_t = 'i'
else:
off_t = 'lxxxx'
pid_t = 'l'
lockdata = struct.pack(off_t + off_t + pid_t + 'hh', 0, 0, 0,
fcntl.F_WRLCK, 0)
elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']:
lockdata = struct.pack('hhlllii', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
elif sys.platform in ['os2emx']:
lockdata = None
else:
lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
if lockdata:
if verbose:
print 'struct.pack: ', repr(lockdata)
return lockdata
示例3: get_lockdata
# 需要导入模块: import os [as 别名]
# 或者: from os import O_LARGEFILE [as 别名]
def get_lockdata():
try:
os.O_LARGEFILE
except AttributeError:
start_len = "ll"
else:
start_len = "qq"
if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd', 'bsdos'))
or sys.platform == 'darwin'):
if struct.calcsize('l') == 8:
off_t = 'l'
pid_t = 'i'
else:
off_t = 'lxxxx'
pid_t = 'l'
lockdata = struct.pack(off_t + off_t + pid_t + 'hh', 0, 0, 0,
fcntl.F_WRLCK, 0)
elif sys.platform.startswith('gnukfreebsd'):
lockdata = struct.pack('qqihhi', 0, 0, 0, fcntl.F_WRLCK, 0, 0)
elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']:
lockdata = struct.pack('hhlllii', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
else:
lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
if lockdata:
if verbose:
print('struct.pack: ', repr(lockdata))
return lockdata
示例4: __init__
# 需要导入模块: import os [as 别名]
# 或者: from os import O_LARGEFILE [as 别名]
def __init__(self, path):
self.fd = None
self.fd = os.open(path, os.O_RDONLY|O_LARGEFILE|O_NOFOLLOW|os.O_NDELAY)
示例5: get_lockdata
# 需要导入模块: import os [as 别名]
# 或者: from os import O_LARGEFILE [as 别名]
def get_lockdata():
try:
os.O_LARGEFILE
except AttributeError:
start_len = "ll"
else:
start_len = "qq"
if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd'))
or sys.platform == 'darwin'):
if struct.calcsize('l') == 8:
off_t = 'l'
pid_t = 'i'
else:
off_t = 'lxxxx'
pid_t = 'l'
lockdata = struct.pack(off_t + off_t + pid_t + 'hh', 0, 0, 0,
fcntl.F_WRLCK, 0)
elif sys.platform.startswith('gnukfreebsd'):
lockdata = struct.pack('qqihhi', 0, 0, 0, fcntl.F_WRLCK, 0, 0)
elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']:
lockdata = struct.pack('hhlllii', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
else:
lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
if lockdata:
if verbose:
print('struct.pack: ', repr(lockdata))
return lockdata