Return an opened file with the given mode. If ensure is True, create parent directories if needed.
(self, mode="r", ensure=False, encoding=None)
| 747 | return obj |
| 748 | |
| 749 | def open(self, mode=class="st">"r", ensure=False, encoding=None): |
| 750 | class="st">"""Return an opened file with the given mode. |
| 751 | |
| 752 | If ensure is True, create parent directories if needed. |
| 753 | class="st">""" |
| 754 | if ensure: |
| 755 | self.dirpath().ensure(dir=1) |
| 756 | if encoding: |
| 757 | return error.checked_call( |
| 758 | io.open, |
| 759 | self.strpath, |
| 760 | mode, |
| 761 | encoding=encoding, |
| 762 | ) |
| 763 | return error.checked_call(open, self.strpath, mode) |
| 764 | |
| 765 | def _fastjoin(self, name): |
| 766 | child = object.__new__(self.__class__) |