libcryfs/src/fspp/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_
2014-11-16 00:10:29 +01:00
#include <fspp/fs_interface/File.h>
#include <fspp/fs_interface/OpenFile.h>
#include "fspp/utils/macros.h"
#include "IdList.h"
2014-11-16 00:05:28 +01:00
namespace fspp {
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-16 00:58:46 +01:00
inline FuseOpenFileList::~FuseOpenFileList() {
}
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);
}
}
2014-11-16 00:05:28 +01:00
#endif /* FSPP_IMPL_FUSEOPENFILELIST_H_ */