about summary refs log blame commit diff
path: root/third_party/nix/src/libstore/fs-accessor.hh
blob: 1bc1373dcb2f73c5d0f2abe76ec01884dff8f330 (plain) (tree)
1
2
3
4
5
6
7
8

            
                           




                                                                     


                                                         
 





                                                     
 
                          
 
                                          
 
                                                        
 
                                                     
 
                                                     

  
                   
#pragma once

#include "libutil/types.hh"

namespace nix {

/* An abstract class for accessing a filesystem-like structure, such
   as a (possibly remote) Nix store or the contents of a NAR file. */
class FSAccessor {
 public:
  enum Type { tMissing, tRegular, tSymlink, tDirectory };

  struct Stat {
    Type type = tMissing;
    uint64_t fileSize = 0;      // regular files only
    bool isExecutable = false;  // regular files only
    uint64_t narOffset = 0;     // regular files only
  };

  virtual ~FSAccessor() {}

  virtual Stat stat(const Path& path) = 0;

  virtual StringSet readDirectory(const Path& path) = 0;

  virtual std::string readFile(const Path& path) = 0;

  virtual std::string readLink(const Path& path) = 0;
};

}  // namespace nix