def touch(self, path, mode=0o644, dir_fd=None, **kwargs):
"""Create an empty file with selected permissions.
Args:
path (str): File path.
mode (:obj:`int`, optional): File access mode. Defaults to 0o644.
dir_fd (optional): If set, it should be a file descriptor open to a
directory and path should then be relative to that directory.
Defaults to None.
**kwargs: Arbitrary keyword arguments.
"""
flags = os.O_CREAT | os.O_APPEND
with os.fdopen(
os.open(path, flags=flags, mode=mode, dir_fd=dir_fd) ) as f:
os.utime(
f.fileno() if os.utime in os.supports_fd else path,
dir_fd=None if os.supports_fd else dir_fd,
**kwargs )
评论列表
文章目录