cppfs  1.2.0.5b71c2c98fb9
Cross-platform C++ file system library supporting multiple backends (Local-FS, SSH)
posix/LocalFileHandle.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 
5 #include <memory>
6 
8 
9 
10 namespace cppfs
11 {
12 
13 
14 class LocalFileSystem;
15 
16 
22 {
23 public:
33  LocalFileHandle(std::shared_ptr<LocalFileSystem> fs, const std::string & path);
34 
44  LocalFileHandle(std::shared_ptr<LocalFileSystem> fs, std::string && path);
45 
50  virtual ~LocalFileHandle();
51 
52  // Virtual AbstractFileHandleBackend functions
53  virtual std::unique_ptr<AbstractFileHandleBackend> clone() const override;
54  virtual AbstractFileSystem * fs() const override;
55  virtual void updateFileInfo() override;
56  virtual std::string path() const override;
57  virtual bool exists() const override;
58  virtual bool isFile() const override;
59  virtual bool isDirectory() const override;
60  virtual bool isSymbolicLink() const override;
61  virtual std::vector<std::string> listFiles() const override;
62  virtual std::unique_ptr<AbstractFileIteratorBackend> begin() const override;
63  virtual unsigned int size() const override;
64  virtual unsigned int accessTime() const override;
65  virtual unsigned int modificationTime() const override;
66  virtual unsigned int userId() const override;
67  virtual void setUserId(unsigned int uid) override;
68  virtual unsigned int groupId() const override;
69  virtual void setGroupId(unsigned int gid) override;
70  virtual unsigned long permissions() const override;
71  virtual void setPermissions(unsigned long permissions) override;
72  virtual bool createDirectory() override;
73  virtual bool removeDirectory() override;
74  virtual bool copy(AbstractFileHandleBackend & dest) override;
75  virtual bool move(AbstractFileHandleBackend & dest) override;
76  virtual bool createLink(AbstractFileHandleBackend & dest) override;
77  virtual bool createSymbolicLink(AbstractFileHandleBackend & dest) override;
78  virtual bool rename(const std::string & filename) override;
79  virtual bool remove() override;
80  virtual std::unique_ptr<std::istream> createInputStream(std::ios_base::openmode mode) const override;
81  virtual std::unique_ptr<std::ostream> createOutputStream(std::ios_base::openmode mode) override;
82 
83 
84 protected:
85  void readFileInfo() const;
86  void readLinkInfo() const;
87 
88 
89 protected:
90  std::shared_ptr<LocalFileSystem> m_fs;
91  std::string m_path;
92  mutable void * m_fileInfo;
93  mutable void * m_linkInfo;
94 };
95 
96 
97 } // namespace cppfs
File handle for the local file system.
Definition: posix/LocalFileHandle.h:21
std::shared_ptr< LocalFileSystem > m_fs
File system that created this handle.
Definition: posix/LocalFileHandle.h:90
Interface for file handles.
Definition: AbstractFileHandleBackend.h:26
Definition: AbstractFileHandleBackend.h:14
void * m_fileInfo
Information about the current file (resolves links, created on demand)
Definition: posix/LocalFileHandle.h:92
Interface for accessing file systems.
Definition: AbstractFileSystem.h:21
void * m_linkInfo
Information about the current file (does not resolve links, created on demand)
Definition: posix/LocalFileHandle.h:93
std::string m_path
Path to file or directory.
Definition: posix/LocalFileHandle.h:91