def get_info(self, path, buffer, file_info): ''' Get file or directory information path {string}: directory path buffer {buffer}: buffer to store file/directory information file_info {Object}: directory information ''' path = _normalize_path_win_to_DB_lower(path) res = self.db.view('file/byFullPath', key=path) if len(res) > 0: # File for doc in res: if path.find('~') == -1: # Standard file buffer[0].dwFileAttributes = FILE_ATTRIBUTE_NORMAL else: # Temporary file buffer[0].dwFileAttributes = FILE_ATTRIBUTE_HIDDEN if 'size' in doc.value: win_size = SizeConvert(doc.value['size']).convert() else: win_size = SizeConvert(1).convert() buffer[0].nFileSizeHigh = win_size[0] buffer[0].nFileSizeLow = win_size[1] buffer[0].nNumberOfLinks = 1 win_index = SizeConvert(2).convert() buffer[0].nFileIndexHigh = win_index[0] buffer[0].nFileIndexLow = win_index[1] lastModification = doc.value['lastModification'].split(' GMT')[0] dt_converter = DateTimeConvertor(datetime.strptime(lastModification, '%a %b %d %Y %H:%M:%S')) dc = dt_converter.convert() if 'creationDate' in doc.value: creationDate = doc.value['creationDate'].split(' GMT')[0] dt_converter_creation = DateTimeConvertor(datetime.strptime(creationDate, '%a %b %d %Y %H:%M:%S')) buffer[0].ftCreationTime = dt_converter_creation.convert() else: buffer[0].ftCreationTime = dc buffer[0].ftLastAccessTime = dc buffer[0].ftLastWriteTime = dc else: res = self.db.view('folder/byFullPath', key=path) if len(res) > 0 or path is '\\': # Folder buffer[0].dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY buffer[0].nFileSizeHigh = 0 buffer[0].nFileSizeLow = 0 buffer[0].nNumberOfLinks = 1 win_index = SizeConvert(1).convert() buffer[0].nFileIndexHigh = win_index[0] buffer[0].nFileIndexLow = win_index[1] dt_converter = DateTimeConvertor(datetime.today()) dc = dt_converter.convert() buffer[0].ftCreationTime = dc buffer[0].ftLastAccessTime = dc buffer[0].ftLastWriteTime = dc else: # Document doesn't exist return -ERROR_FILE_NOT_FOUND buffer[0].dwVolumeSerialNumber = self.serial_number return 0
def reversePath(path): cindex = path.find('cache/') if cindex == -1 or path[-6:] != '.cache': raise Exception( "I expect a full cached filepath 'cache/<domain>/<path>.cache'. {0} does not match" .format(path)) path = path[cindex + 6:-6] return path.replace('^', '/')
def reversePath(path): cindex = path.find('cache/') if cindex == -1 or path[-6:] != '.cache': raise Exception("I expect a full cached filepath 'cache/<domain>/<path>.cache'. {0} does not match".format(path)) path = path[cindex+6:-6] return path.replace('^','/')