Create this file with the given access mode, if it doesn't exist.
(self, mode=0o666, exist_ok=True)
| 1180 | raise UnsupportedOperation(f"{f} is unsupported on this system") |
| 1181 | |
| 1182 | def touch(self, mode=0o666, exist_ok=True): |
| 1183 | """ |
| 1184 | Create this file with the given access mode, if it doesn't exist. |
| 1185 | """ |
| 1186 | |
| 1187 | if exist_ok: |
| 1188 | # First try to bump modification time |
| 1189 | # Implementation note: GNU touch uses the UTIME_NOW option of |
| 1190 | # the utimensat() / futimens() functions. |
| 1191 | try: |
| 1192 | os.utime(self, None) |
| 1193 | except OSError: |
| 1194 | # Avoid exception chaining |
| 1195 | pass |
| 1196 | else: |
| 1197 | return |
| 1198 | flags = os.O_CREAT | os.O_WRONLY |
| 1199 | if not exist_ok: |
| 1200 | flags |= os.O_EXCL |
| 1201 | fd = os.open(self, flags, mode) |
| 1202 | os.close(fd) |
| 1203 | |
| 1204 | def mkdir(self, mode=0o777, parents=False, exist_ok=False): |
| 1205 | """ |