Inode.h revision 63db34c8
1/*
2 * Copyright 2008, Axel D��rfler, axeld@pinc-software.de.
3 * This file may be used under the terms of the MIT License.
4 */
5#ifndef INODE_H
6#define INODE_H
7
8
9#include <lock.h>
10
11#include "ext2.h"
12#include "Volume.h"
13
14
15class Inode {
16public:
17						Inode(Volume* volume, ino_t id);
18						~Inode();
19
20			status_t	InitCheck();
21
22			ino_t		ID() const { return fID; }
23
24			rw_lock*	Lock() { return &fLock; }
25
26			bool		IsDirectory() const
27							{ return S_ISDIR(Mode()); }
28			bool		IsFile() const
29							{ return S_ISREG(Mode()); }
30			bool		IsSymLink() const
31							{ return S_ISLNK(Mode()); }
32
33			status_t	CheckPermissions(int accessMode) const;
34
35			mode_t		Mode() const { return fNode->Mode(); }
36			int32		Flags() const { return fNode->Flags(); }
37
38			off_t		Size() const { return fNode->Size(); }
39			time_t		ModificationTime() const
40							{ return fNode->ModificationTime(); }
41			time_t		CreationTime() const
42							{ return fNode->CreationTime(); }
43			time_t		AccessTime() const
44							{ return fNode->AccessTime(); }
45
46			//::Volume* _Volume() const { return fVolume; }
47			Volume*		GetVolume() const { return fVolume; }
48
49			status_t	FindBlock(off_t offset, uint32& block);
50			status_t	ReadAt(off_t pos, uint8 *buffer, size_t *length);
51
52			ext2_inode&	Node() { return *fNode; }
53
54			void*		FileCache() const { return fCache; }
55			void*		Map() const { return fMap; }
56
57private:
58						Inode(const Inode&);
59						Inode &operator=(const Inode&);
60							// no implementation
61
62private:
63	rw_lock				fLock;
64	::Volume*			fVolume;
65	ino_t				fID;
66	void*				fCache;
67	void*				fMap;
68	ext2_inode*			fNode;
69};
70
71#endif	// INODE_H
72