def test_utime(self): if hasattr(posix, 'utime'): now = time.time() posix.utime(test_support.TESTFN, None) self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None)) self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None)) self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now)) posix.utime(test_support.TESTFN, (int(now), int(now))) posix.utime(test_support.TESTFN, (now, now))
def set_default_time(self): # TODO: get the way to modify file's created time """set the file's access time and modified time to his default time""" for current_path, sub_folders, file_names in os.walk(self.path): for folder in sub_folders: posix.utime("{}/{}".format(current_path, folder), (self.a_time_stamp, self.m_time_stamp)) for file in file_names: posix.utime("{}/{}".format(current_path, file), (self.a_time_stamp, self.m_time_stamp)) posix.utime(self.path, (self.a_time_stamp, self.m_time_stamp))
def set_original_time(self): # TODO: get the way to modify file's created time """set the file's access time and modified time to his original time""" data = self.read_cm_time() for current_path, sub_folders, file_names in os.walk(self.path): time_dic = data[current_path] for folder in sub_folders: time_temp = time_dic[folder] posix.utime("{}/{}".format(current_path, folder), (time_temp[0], time_temp[1])) for file in file_names: time_temp = time_dic[file] posix.utime("{}/{}".format(current_path, file), (time_temp[0], time_temp[1])) posix.utime(self.path, (data['top'][0], data['top'][1]))
def test_utime(self): if hasattr(posix, 'utime'): now = time.time() posix.utime(test_support.TESTFN, None) posix.utime(test_support.TESTFN, (now, now))