<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_files(self, set_length=True, check_length=True):
 """Check all files in self.resources, find longest common prefix. Go though and check all files in self.resources, add up size, and find longest common path that can be used when writing the dump file. Saved in self.path_prefix. Parameters set_length and check_length control control whether then set_length attribute should be set from the file size if not specified, and whether any length specified should be checked. By default both are True. In any event, the total size calculated is the size of files on disk. """

        total_size = 0  # total size of all files in bytes
        path_prefix = None
        for resource in self.resources:
            if (resource.path is None):
                # explicit test because exception raised by getsize otherwise
                # confusing
                raise DumpError(
                    "No file path defined for resource %s" %
                    resource.uri)
            if (path_prefix is None):
                path_prefix = os.path.dirname(resource.path)
            else:
                path_prefix = os.path.commonprefix(
                    [path_prefix, os.path.dirname(resource.path)])
            size = os.path.getsize(resource.path)
            if (resource.length is not None):
                if (check_length and resource.length != size):
                    raise DumpError("Size of resource %s is %d on disk, not %d as specified" %
                                    (resource.uri, size, resource.length))
            elif (set_length):
                resource.length = size
            if (size > self.max_size):
                raise DumpError(
                    "Size of file (%s, %d) exceeds maximum (%d) dump size" %
                    (resource.path, size, self.max_size))
            total_size += size
        self.path_prefix = path_prefix
        self.total_size = total_size
        self.logger.info(
            "Total size of files to include in dump %d bytes" %
            (total_size))
        return True