| 89 | |
| 90 | # Read directory file into the in-memory index dict. |
| 91 | def _update(self, flag): |
| 92 | self._modified = False |
| 93 | self._index = {} |
| 94 | try: |
| 95 | f = _io.open(self._dirfile, 'r', encoding="Latin-1") |
| 96 | except OSError: |
| 97 | if flag not in ('c', 'n'): |
| 98 | raise |
| 99 | with self._io.open(self._dirfile, 'w', encoding="Latin-1") as f: |
| 100 | self._chmod(self._dirfile) |
| 101 | else: |
| 102 | with f: |
| 103 | for line in f: |
| 104 | line = line.rstrip() |
| 105 | key, pos_and_siz_pair = _ast.literal_eval(line) |
| 106 | key = key.encode('Latin-1') |
| 107 | self._index[key] = pos_and_siz_pair |
| 108 | |
| 109 | # Write the index dict to the directory file. The original directory |
| 110 | # file (if any) is renamed with a .bak extension first. If a .bak |