code: def add_file(self, resource_list=None, dir=None, file=None):
          
          try:
              if self.exclude_file(file):
                  self.logger.debug("Excluding file %s" % (file))
                  return
              # get abs filename and also URL
              if (dir is not None):
                  file = os.path.join(dir, file)
              if (not os.path.isfile(file) or not (
                      self.include_symlinks or not os.path.islink(file))):
                  return
              uri = self.mapper.dst_to_src(file)
              if (uri is None):
                  raise Exception("Internal error, mapping failed")
              file_stat = os.stat(file)
          except OSError as e:
              sys.stderr.write("Ignoring file %s (error: %s)" % (file, str(e)))
              return
          timestamp = file_stat.st_mtime  # UTC
          r = Resource(uri=uri, timestamp=timestamp)
          if (self.set_path):
              # add full local path
              r.path = file
          if (self.set_hashes):
              hasher = Hashes(self.set_hashes, file)
              if ('md5' in self.set_hashes):
                  r.md5 = hasher.md5
              if ('sha-1' in self.set_hashes):
                  r.sha1 = hasher.sha1
              if ('sha-256' in self.set_hashes):
                  r.sha256 = hasher.sha256
          if (self.set_length):
              # add length
              r.length = file_stat.st_size
          resource_list.add(r)
docs: Add a single file to resource_list.
  
          Follows object settings of set_path, set_hashes and set_length.