Move stat_info and statvfs to Types.h

This commit is contained in:
Sebastian Messmer 2018-09-14 01:37:33 -07:00
parent ac63b5af85
commit 8f2fc3b6b8
6 changed files with 45 additions and 26 deletions

View File

@ -7,7 +7,7 @@ set(SOURCES
Node.cpp
OpenFile.cpp
Symlink.cpp
)
Types.cpp)
add_library(${PROJECT_NAME} STATIC ${SOURCES})

View File

@ -4,6 +4,7 @@
#include <boost/filesystem.hpp>
#include <cpp-utils/pointer/unique_ref.h>
#include "Types.h"
namespace fspp {
class Node;
@ -15,18 +16,7 @@ class Device {
public:
virtual ~Device() {}
struct statvfs final {
uint32_t max_filename_length;
uint32_t blocksize;
uint64_t num_total_blocks;
uint64_t num_free_blocks;
uint64_t num_available_blocks; // free blocks for unprivileged users
uint64_t num_total_inodes;
uint64_t num_free_inodes;
uint64_t num_available_inodes; // free inodes for unprivileged users
};
using statvfs = fspp::statvfs;
virtual statvfs statfs(const boost::filesystem::path &path) = 0;
virtual boost::optional<cpputils::unique_ref<Node>> Load(const boost::filesystem::path &path) = 0;

View File

@ -3,6 +3,7 @@
#define MESSMER_FSPP_FSINTERFACE_NODE_H_
#include <boost/filesystem.hpp>
#include "Types.h"
namespace fspp {
@ -10,17 +11,7 @@ class Node {
public:
virtual ~Node() {}
struct stat_info final {
uint32_t nlink;
uint32_t mode;
uint32_t uid;
uint32_t gid;
uint64_t size;
uint64_t blocks;
struct timespec atime;
struct timespec mtime;
struct timespec ctime;
};
using stat_info = fspp::stat_info;
virtual stat_info stat() const = 0;
virtual void chmod(mode_t mode) = 0;

View File

@ -3,7 +3,7 @@
#define MESSMER_FSPP_FSINTERFACE_OPENFILE_H_
#include <boost/filesystem.hpp>
#include "Node.h"
#include "Types.h"
namespace fspp {
class Device;
@ -12,7 +12,7 @@ class OpenFile {
public:
virtual ~OpenFile() {}
using stat_info = typename Node::stat_info;
using stat_info = fspp::stat_info;
virtual stat_info stat() const = 0;
virtual void truncate(off_t size) const = 0;

View File

@ -0,0 +1 @@
#include "Types.h"

View File

@ -0,0 +1,37 @@
#pragma once
#ifndef MESSMER_FSPP_FSINTERFACE_TYPES_H_
#define MESSMER_FSPP_FSINTERFACE_TYPES_H_
#include <cstdint>
#include <ctime>
namespace fspp {
struct stat_info final {
uint32_t nlink;
uint32_t mode;
uint32_t uid;
uint32_t gid;
uint64_t size;
uint64_t blocks;
struct timespec atime;
struct timespec mtime;
struct timespec ctime;
};
struct statvfs final {
uint32_t max_filename_length;
uint32_t blocksize;
uint64_t num_total_blocks;
uint64_t num_free_blocks;
uint64_t num_available_blocks; // free blocks for unprivileged users
uint64_t num_total_inodes;
uint64_t num_free_inodes;
uint64_t num_available_inodes; // free inodes for unprivileged users
};
}
#endif