libcryfs/src/fusepp/impl/FuseOpenFileList.h

47 lines
993 B
C
Raw Normal View History

#pragma once
#ifndef FUSEPP_FUSEOPENFILELIST_H_
#define FUSEPP_FUSEOPENFILELIST_H_
2014-11-15 23:47:38 +01:00
#include <fusepp/fs_interface/File.h>
#include <fusepp/fs_interface/OpenFile.h>
#include "fusepp/utils/macros.h"
#include "IdList.h"
namespace fusepp {
class FuseOpenFileList {
public:
FuseOpenFileList();
virtual ~FuseOpenFileList();
2014-11-15 23:47:38 +01:00
int open(const File &rhs, int flags);
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-15 23:47:38 +01:00
inline int FuseOpenFileList::open(const File &file, int flags) {
return _open_files.add(file.open(flags));
}
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);
}
}
#endif /* FUSEPP_FUSEOPENFILELIST_H_ */