From 13f19719b25e3bb2f9b2003ff6368d50b9ac8aa5 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 2 Mar 2020 17:46:19 -0800 Subject: [PATCH] Add Pathclass.touch. --- voussoirkit/pathclass.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/voussoirkit/pathclass.py b/voussoirkit/pathclass.py index 3566781..c1a4321 100644 --- a/voussoirkit/pathclass.py +++ b/voussoirkit/pathclass.py @@ -241,6 +241,12 @@ class Path: def stat(self): return os.stat(self.absolute_path) + def touch(self): + try: + os.utime(self.absolute_path) + except FileNotFoundError: + open(self.absolute_path, 'a').close() + def walk(self): directories = [] for child in self.listdir():