2 * Copyright 2001-2008, pinc Software. All Rights Reserved.
8 #include <SupportDefs.h>
18 Inode(Disk
* disk
, bfs_inode
* inode
, bool ownBuffer
= true);
19 Inode(const Inode
&inode
);
22 status_t
SetTo(bfs_inode
*inode
);
23 virtual status_t
InitCheck() const;
25 bool IsFile() const { return S_ISREG(fInode
->mode
); }
26 bool IsDirectory() const { return S_ISDIR(fInode
->mode
); }
27 bool IsSymlink() const { return S_ISLNK(fInode
->mode
); }
28 bool IsIndex() const { return S_ISINDEX(fInode
->mode
); }
29 bool IsAttribute() const
30 { return (fInode
->mode
& S_ATTR
) != 0; }
31 bool IsAttributeDirectory() const
32 { return (fInode
->mode
& S_ATTR_DIR
) != 0; }
33 bool IsRoot() const { return BlockRun() == fDisk
->Root(); }
35 int32
Mode() const { return fInode
->mode
; }
36 int32
Flags() const { return fInode
->flags
; }
37 off_t
Size() const { return fInode
->data
.size
; }
40 { return fDisk
->ToOffset(BlockRun()); }
41 off_t
Block() const { return fDisk
->ToBlock(BlockRun()); }
42 const block_run
& BlockRun() const { return fBlockRun
; }
43 block_run
Parent() const { return fInode
->parent
; }
44 block_run
Attributes() const { return fInode
->attributes
; }
46 const bfs_inode
* InodeBuffer() const { return fInode
; }
47 status_t
CopyBuffer();
50 status_t
AcquireBuffer();
51 void BufferClobbered();
53 void SetParent(const block_run
& run
);
54 void SetBlockRun(const block_run
& run
);
55 void SetMode(uint32 mode
);
57 status_t
SetName(const char* name
);
58 const char* Name() const;
59 status_t
GetNextSmallData(small_data
** smallData
);
61 status_t
RewindAttributes();
62 status_t
GetNextAttribute(char* name
, uint32
* type
, void** data
,
66 const char* Path(Inode::Source
* source
= NULL
);
67 virtual status_t
CopyTo(const char* path
, bool fullPath
= true,
68 Inode::Source
* source
= NULL
);
69 status_t
CopyAttributesTo(BNode
* node
);
71 static Inode
* Factory(Disk
* disk
, bfs_inode
* inode
,
72 bool ownBuffer
= true);
73 static Inode
* Factory(Disk
* disk
, block_run run
);
74 static Inode
* Factory(Disk
* disk
, Inode
* inode
,
75 bool copyBuffer
= true);
77 static Inode
* EmptyInode(Disk
* disk
,const char* name
, int32 mode
);
81 virtual Inode
*InodeAt(block_run run
) = 0;
85 static bool _LowMemory();
87 status_t
_FindPath(Inode::Source
*source
= NULL
);
96 small_data
*fCurrentSmallData
;
97 Directory
*fAttributes
;
98 void *fAttributeBuffer
;
102 class DataStream
: public Inode
, public BPositionIO
{
104 DataStream(Disk
*disk
, bfs_inode
*inode
, bool ownBuffer
= true);
105 DataStream(const Inode
&inode
);
108 status_t
FindBlockRun(off_t pos
);
110 virtual ssize_t
ReadAt(off_t pos
, void *buffer
, size_t size
);
111 virtual ssize_t
WriteAt(off_t pos
, const void *buffer
, size_t size
);
113 virtual off_t
Seek(off_t position
, uint32 seek_mode
);
114 virtual off_t
Position() const;
116 virtual status_t
SetSize(off_t size
);
122 off_t fRunFileOffset
;
128 class File
: public DataStream
{
130 File(Disk
*disk
, bfs_inode
*inode
, bool ownBuffer
= true);
131 File(const Inode
&inode
);
134 virtual status_t
InitCheck() const;
135 virtual status_t
CopyTo(const char *path
, bool fullPath
= true,
136 Inode::Source
*source
= NULL
);
140 class Attribute
: public File
{
142 Attribute(Disk
*disk
, bfs_inode
*inode
, bool ownBuffer
= true);
143 Attribute(const Inode
&inode
);
146 virtual status_t
InitCheck() const;
147 virtual status_t
CopyTo(const char *path
, bool fullPath
= true,
148 Inode::Source
*source
= NULL
);
150 uint32
Type() const { return fInode
->type
; }
154 class Directory
: public DataStream
{
156 Directory(Disk
*disk
, bfs_inode
*inode
, bool ownBuffer
= true);
157 Directory(const Inode
&inode
);
160 virtual status_t
InitCheck() const;
161 virtual status_t
CopyTo(const char *path
, bool fullPath
= true,
162 Inode::Source
*source
= NULL
);
164 virtual status_t
Rewind();
165 virtual status_t
GetNextEntry(char *name
, block_run
*run
);
166 virtual status_t
GetNextEntry(block_run
*run
);
168 virtual status_t
Contains(const block_run
*run
);
169 virtual status_t
Contains(const Inode
*inode
);
170 virtual status_t
FindEntry(const char *name
, block_run
*run
);
172 virtual status_t
AddEntry(Inode
*inode
);
174 status_t
GetTree(BPlusTree
**tree
);
177 virtual status_t
CreateTree();
183 class Symlink
: public Inode
{
185 Symlink(Disk
*disk
, bfs_inode
*inode
, bool ownBuffer
= true);
186 Symlink(const Inode
&inode
);
189 virtual status_t
InitCheck() const;
190 virtual status_t
CopyTo(const char *path
, bool fullPath
= true,
191 Inode::Source
*source
= NULL
);
193 status_t
LinksTo(char *to
, size_t maxLength
);