48 lines
942 B
C++
48 lines
942 B
C++
// Ext2OpenFile.h
|
|
// Author: Josh Holtrop
|
|
// Date: 12/26/05
|
|
// Modified: 12/26/05
|
|
|
|
#ifndef __HOS_EXT2OPENFILE__
|
|
#define __HOS_EXT2OPENFILE__ __HOS_EXT2OPENFILE__
|
|
|
|
#include "ext2.h"
|
|
#include "fs/OpenFile.h"
|
|
#include "Ext2BlockCache.h"
|
|
|
|
class Ext2OpenFile : public OpenFile
|
|
{
|
|
protected:
|
|
Ext2fs *myFS;
|
|
u32_t myInum;
|
|
int myMode;
|
|
int myBeenTruncated; /* set true when the file truncated */
|
|
u32_t myPosition;
|
|
u32_t myBlockSize;
|
|
Ext2BlockCache *myCache;
|
|
ext2_inode_t myInode;
|
|
u8_t *myBlockCache;
|
|
u32_t myBlockCacheBlock;
|
|
int myBlockCacheStatus; /* 0: invalid; 1: valid; 2: dirty */
|
|
|
|
void updateCache(u32_t blockNum);
|
|
|
|
public:
|
|
Ext2OpenFile(Ext2fs *fs, u32_t inum, int mode);
|
|
~Ext2OpenFile();
|
|
int seek(int pos, int mode);
|
|
int read();
|
|
int read(void *buf, u32_t num);
|
|
int write(int chr);
|
|
int write(void *buf, u32_t num);
|
|
void notifyTruncated();
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
u32_t inode;
|
|
Ext2OpenFile *ofile;
|
|
} Ext2OpenFileHandle;
|
|
|
|
#endif
|