Beispiel #1
0
 def Stat(self, fname, opts):
     stat = self._GetStat(fname, follow_symlink=opts.resolve_links)
     pathspec = rdf_paths.PathSpec(
         pathtype=rdf_paths.PathSpec.PathType.OS,
         path=client_utils.LocalPathToCanonicalPath(fname),
         path_options=rdf_paths.PathSpec.Options.CASE_LITERAL)
     return files.MakeStatResponse(stat,
                                   pathspec=pathspec,
                                   ext_attrs=opts.collect_ext_attrs)
Beispiel #2
0
  def Stat(self, fname, stat_object, resolve_links):
    if resolve_links and stat.S_ISLNK(stat_object.st_mode):
      try:
        stat_object = os.stat(fname)
      except OSError:
        return

    pathspec = rdf_paths.PathSpec(
        pathtype=rdf_paths.PathSpec.PathType.OS, path=fname)
    return files.MakeStatResponse(stat_object, pathspec=pathspec)
Beispiel #3
0
    def Stat(self, fname, stat_object, resolve_links):
        if resolve_links and stat.S_ISLNK(stat_object.st_mode):
            try:
                stat_object = os.stat(fname)
            except OSError:
                return None

        pathspec = rdf_paths.PathSpec(
            pathtype=rdf_paths.PathSpec.PathType.OS,
            path=client_utils.LocalPathToCanonicalPath(fname),
            path_options=rdf_paths.PathSpec.Options.CASE_LITERAL)
        return files.MakeStatResponse(stat_object, pathspec=pathspec)
Beispiel #4
0
    def Stat(self, fname, stat, opts):
        if opts.resolve_links and stat.IsSymlink():
            try:
                stat = utils.Stat(fname, follow_symlink=True)
            except OSError:
                return None

        pathspec = rdf_paths.PathSpec(
            pathtype=rdf_paths.PathSpec.PathType.OS,
            path=client_utils.LocalPathToCanonicalPath(fname),
            path_options=rdf_paths.PathSpec.Options.CASE_LITERAL)
        return files.MakeStatResponse(stat,
                                      pathspec=pathspec,
                                      ext_attrs=opts.ext_attrs)
Beispiel #5
0
 def ListFiles(self):
     for f in os.listdir(self._AbsPath()):
         ps = self.pathspec.Copy()
         ps.last.path = os.path.join(ps.last.path, f)
         stat = utils.Stat(self._AbsPath(f))
         yield files.MakeStatResponse(stat, ps)
Beispiel #6
0
 def Stat(self):
     """Get Stat for self.path."""
     test_data_path = self._AbsPath()
     stat = utils.Stat(test_data_path)
     return files.MakeStatResponse(stat, self.pathspec)
Beispiel #7
0
def _StatEntry(stat, ext_attrs):
    pathspec = rdf_paths.PathSpec(
        pathtype=rdf_paths.PathSpec.PathType.OS,
        path=client_utils.LocalPathToCanonicalPath(stat.GetPath()),
        path_options=rdf_paths.PathSpec.Options.CASE_LITERAL)
    return files.MakeStatResponse(stat, pathspec=pathspec, ext_attrs=ext_attrs)