MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / touch

Method touch

tools/python-3.11.9-amd64/Lib/pathlib.py:1089–1109  ·  view source on GitHub ↗

Create this file with the given access mode, if it doesn't exist.

(self, mode=0o666, exist_ok=True)

Source from the content-addressed store, hash-verified

1087 return self._from_parts((os.readlink(self),))
1088
1089 def touch(self, mode=0o666, exist_ok=True):
1090 """
1091 Create this file with the given access mode, if it doesn't exist.
1092 """
1093
1094 if exist_ok:
1095 # First try to bump modification time
1096 # Implementation note: GNU touch uses the UTIME_NOW option of
1097 # the utimensat() / futimens() functions.
1098 try:
1099 os.utime(self, None)
1100 except OSError:
1101 # Avoid exception chaining
1102 pass
1103 else:
1104 return
1105 flags = os.O_CREAT | os.O_WRONLY
1106 if not exist_ok:
1107 flags |= os.O_EXCL
1108 fd = os.open(self, flags, mode)
1109 os.close(fd)
1110
1111 def mkdir(self, mode=0o777, parents=False, exist_ok=False):
1112 """

Callers

nothing calls this directly

Calls 3

utimeMethod · 0.80
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected