def generate(self, callback=None, interval=0):
        if self.path is None:
            raise RuntimeError('generate() called with no path specified')
        elif self.size <= 0:
            raise error.PathEmptyError(self.path)
        elif not os.path.exists(self.path):
            raise error.PathNotFoundError(self.path)
        if callback is not None:
            cancel = lambda *status: callback(*status) is not None
        else:
            cancel = lambda *status: False
        if os.path.isfile(self.path):
            pieces = self._set_pieces_singlefile()
        elif os.path.isdir(self.path):
            pieces = self._set_pieces_multifile()
        last_cb_call = 0
        for filepath,pieces_done,pieces_total in pieces:
            now = time.time()
            if now - last_cb_call >= interval or \
               pieces_done >= pieces_total:
                last_cb_call = now
                if cancel(self, filepath, pieces_done, pieces_total):
                    return False
        return True