Create this file with the given access mode, if it doesn't exist.
(self, mode=0o666, exist_ok=True)
| 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 | """ |