2014-11-15 15:16:18 +01:00
|
|
|
#pragma once
|
2014-11-16 00:05:28 +01:00
|
|
|
#ifndef FSPP_IMPL_FUSEOPENFILELIST_H_
|
|
|
|
#define FSPP_IMPL_FUSEOPENFILELIST_H_
|
2014-11-15 15:16:18 +01:00
|
|
|
|
2015-02-17 00:48:49 +01:00
|
|
|
#include "../fs_interface/File.h"
|
|
|
|
#include "../fs_interface/OpenFile.h"
|
|
|
|
#include "messmer/cpp-utils/macros.h"
|
2014-11-15 15:16:18 +01:00
|
|
|
#include "IdList.h"
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
namespace fspp {
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
class FuseOpenFileList {
|
|
|
|
public:
|
|
|
|
FuseOpenFileList();
|
|
|
|
virtual ~FuseOpenFileList();
|
|
|
|
|
2015-06-18 19:30:52 +02:00
|
|
|
int open(cpputils::unique_ref<OpenFile> file);
|
2014-11-15 23:47:38 +01:00
|
|
|
OpenFile *get(int descriptor);
|
2014-11-15 15:16:18 +01:00
|
|
|
void close(int descriptor);
|
|
|
|
|
|
|
|
private:
|
2014-11-15 23:47:38 +01:00
|
|
|
IdList<OpenFile> _open_files;
|
2014-11-15 15:16:18 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(FuseOpenFileList);
|
|
|
|
};
|
|
|
|
|
2014-11-15 16:33:24 +01:00
|
|
|
inline FuseOpenFileList::FuseOpenFileList()
|
|
|
|
:_open_files() {
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:58:46 +01:00
|
|
|
inline FuseOpenFileList::~FuseOpenFileList() {
|
|
|
|
}
|
|
|
|
|
2015-06-18 19:30:52 +02:00
|
|
|
inline int FuseOpenFileList::open(cpputils::unique_ref<OpenFile> file) {
|
2015-03-11 00:22:36 +01:00
|
|
|
return _open_files.add(std::move(file));
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
2014-11-15 23:47:38 +01:00
|
|
|
inline OpenFile *FuseOpenFileList::get(int descriptor) {
|
2014-11-15 16:33:24 +01:00
|
|
|
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-15 15:16:18 +01:00
|
|
|
}
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
#endif /* FSPP_IMPL_FUSEOPENFILELIST_H_ */
|