+ if self._files_p is not None:
+ self._destroy(self._files_p)
+
+ def __len__(self):
+ """len(:class:`Filenames`) returns the number of contained files
+
+ .. note::
+
+ As this iterates over the files, we will not be able to
+ iterate over them again! So this will fail::
+
+ #THIS FAILS
+ files = Database().get_directory('').get_child_files()
+ if len(files) > 0: # this 'exhausts' msgs
+ # next line raises
+ # NotmuchError(:attr:`STATUS`.NOT_INITIALIZED)
+ for file in files: print file
+ """
+ if not self._files_p:
+ raise NotInitializedError()
+
+ i = 0
+ while self._valid(self._files_p):
+ self._move_to_next(self._files_p)
+ i += 1
+ self._files_p = None
+ return i