def add_file(self, filepath, misc_prop=None):
"""Manually add files to the files list, and get all its file
properties.
Keyword arguments:
filepath -- path to file
misc_prop -- add a miscellaneous property
"""
if not os.path.isfile(filepath):
print(filepath + " is not a file.")
return
fp_rel = filepath[self.__path_len:]
try:
stat = os.stat(filepath)
except:
return
file_props = {}
file_props['size'] = stat[ST_SIZE]
file_props['adate'] = stat[ST_ATIME]
file_props['mdate'] = stat[ST_MTIME]
file_props['cdate'] = stat[ST_CTIME]
file_props['name'] = fp_rel
file_props['fullpath'] = filepath
file_props['misc'] = misc_prop
self.__files.append(file_props)
self.__filecount += 1
评论列表
文章目录