libcryfs/src/cryfs_lib/CryDevice.h

61 lines
1.6 KiB
C
Raw Normal View History

#pragma once
#ifndef CRYFS_LIB_CRYDEVICE_H_
#define CRYFS_LIB_CRYDEVICE_H_
#include <boost/filesystem.hpp>
#include <memory>
#include <sys/stat.h>
#include "utils/macros.h"
2014-11-12 15:19:04 +01:00
#include "CryOpenFileList.h"
2014-11-04 17:40:31 +01:00
namespace cryfs {
class CryNode;
class CryFile;
class CryOpenFile;
class CryDir;
namespace bf = boost::filesystem;
class CryDevice {
public:
CryDevice(const bf::path &rootdir);
virtual ~CryDevice();
int openFile(const bf::path &path, int flags);
void closeFile(int descriptor);
void lstat(const bf::path &path, struct ::stat *stbuf);
void fstat(int descriptor, struct ::stat *stbuf);
void truncate(const bf::path &path, off_t size);
void ftruncate(int descriptor, off_t size);
2014-11-11 00:18:24 +01:00
int read(int descriptor, void *buf, size_t count, off_t offset);
void write(int descriptor, const void *buf, size_t count, off_t offset);
void fsync(int descriptor);
void fdatasync(int descriptor);
void access(const bf::path &path, int mask);
2014-11-10 23:51:45 +01:00
int createAndOpenFile(const bf::path &path, mode_t mode);
2014-11-12 12:27:23 +01:00
void mkdir(const bf::path &path, mode_t mode);
2014-11-12 12:34:35 +01:00
void rmdir(const bf::path &path);
2014-11-12 12:31:38 +01:00
void unlink(const bf::path &path);
2014-11-12 12:43:49 +01:00
void rename(const bf::path &from, const bf::path &to);
const bf::path &RootDir() const;
private:
std::unique_ptr<CryNode> Load(const bf::path &path);
std::unique_ptr<CryFile> LoadFile(const bf::path &path);
std::unique_ptr<CryDir> LoadDir(const bf::path &path);
2014-11-12 12:27:23 +01:00
int openFile(const CryFile &file, int flags);
const bf::path _rootdir;
CryOpenFileList _open_files;
DISALLOW_COPY_AND_ASSIGN(CryDevice);
};
inline const bf::path &CryDevice::RootDir() const {
return _rootdir;
}
}
#endif /* CRYFS_LIB_CRYDEVICE_H_ */