xref: /haiku/src/system/boot/loader/file_systems/bfs/Stream.h (revision 893988af824e65e49e55f517b157db8386e8002b)
1 /* Stream - inode stream access functions
2 **
3 ** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
4 ** Distributed under the terms of the OpenBeOS License.
5 */
6 #ifndef STREAM_H
7 #define STREAM_H
8 
9 
10 #include "Volume.h"
11 
12 #include <sys/stat.h>
13 
14 class Node;
15 
16 
17 namespace BFS {
18 
19 class Stream : public bfs_inode {
20 	public:
21 		Stream(Volume &volume, block_run run);
22 		Stream(Volume &volume, off_t id);
23 		~Stream();
24 
25 		status_t InitCheck();
26 		Volume &GetVolume() const { return fVolume; }
27 
28 		status_t FindBlockRun(off_t pos, block_run &run, off_t &offset);
29 		status_t ReadAt(off_t pos, uint8 *buffer, size_t *length);
30 
31 		status_t GetName(char *name, size_t size) const;
32 		off_t Size() const { return data.Size(); }
33 		off_t ID() const { return fVolume.ToVnode(inode_num); }
34 		status_t ReadLink(char *buffer, size_t bufferSize);
35 
36 		bool IsContainer() const { return Mode() & (S_IFDIR | S_INDEX_DIR | S_ATTR_DIR); }
37 		bool IsSymlink() const { return S_ISLNK(Mode()); }
38 
39 		static Node *NodeFactory(Volume &volume, off_t id);
40 
41 	private:
42 		status_t GetNextSmallData(const small_data **_smallData) const;
43 
44 		Volume	&fVolume;
45 };
46 
47 }	// namespace BFS
48 
49 #endif	/* STREAM_H */
50