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 MIT 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 bool IsIndex() const { return false; } 39 40 static Node *NodeFactory(Volume &volume, off_t id); 41 42 private: 43 status_t GetNextSmallData(const small_data **_smallData) const; 44 45 Volume &fVolume; 46 }; 47 48 } // namespace BFS 49 50 #endif /* STREAM_H */ 51