def add_file(self, filepath, misc_prop=None):
"""Add a file to the file repo.
Keyword arguments:
filepath -- path to file
misc_props -- string to add as a 'misc' property to file
"""
if not path.isfile(filepath):
print(filepath + " is not a file.")
exit(1)
fp_rel = filepath[self.__path_len:]
try:
filestat = stat(filepath)
except:
return
file_props = {}
file_props['size'] = filestat[ST_SIZE]
file_props['adate'] = filestat[ST_ATIME]
file_props['mdate'] = filestat[ST_MTIME]
file_props['cdate'] = filestat[ST_CTIME]
file_props['name'] = fp_rel
file_props['fullpath'] = filepath
file_props['misc'] = misc_prop
self.__file_list.append(file_props)
self.__filecount += 1
评论列表
文章目录