libcryfs/impl/FuseOpenFileList.h

50 lines
1.0 KiB
C
Raw Normal View History

#pragma once
2014-11-16 00:05:28 +01:00
#ifndef FSPP_IMPL_FUSEOPENFILELIST_H_
#define FSPP_IMPL_FUSEOPENFILELIST_H_
2015-02-17 00:48:49 +01:00
#include "../fs_interface/File.h"
#include "../fs_interface/OpenFile.h"
#include "messmer/cpp-utils/macros.h"
#include "IdList.h"
2014-11-16 00:05:28 +01:00
namespace fspp {
class FuseOpenFileList {
public:
FuseOpenFileList();
virtual ~FuseOpenFileList();
int open(std::unique_ptr<OpenFile> file);
2014-11-15 23:47:38 +01:00
OpenFile *get(int descriptor);
void close(int descriptor);
private:
2014-11-15 23:47:38 +01:00
IdList<OpenFile> _open_files;
DISALLOW_COPY_AND_ASSIGN(FuseOpenFileList);
};
inline FuseOpenFileList::FuseOpenFileList()
:_open_files() {
}
2014-11-16 00:58:46 +01:00
inline FuseOpenFileList::~FuseOpenFileList() {
}
inline int FuseOpenFileList::open(std::unique_ptr<OpenFile> file) {
return _open_files.add(std::move(file));
}
2014-11-15 23:47:38 +01:00
inline OpenFile *FuseOpenFileList::get(int descriptor) {
return _open_files.get(descriptor);
}
inline void FuseOpenFileList::close(int descriptor) {
//The destructor of the stored FuseOpenFile closes the file
_open_files.remove(descriptor);
}
}
2014-11-16 00:05:28 +01:00
#endif /* FSPP_IMPL_FUSEOPENFILELIST_H_ */