1 /* 2 * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. 3 * This file may be used under the terms of the MIT License. 4 */ 5 6 7 #include "File.h" 8 9 10 namespace BFS { 11 12 13 File::File(Volume &volume, block_run run) 14 : 15 fStream(volume, run) 16 { 17 } 18 19 20 File::File(Volume &volume, off_t id) 21 : 22 fStream(volume, id) 23 { 24 } 25 26 27 File::File(const Stream &stream) 28 : 29 fStream(stream) 30 { 31 } 32 33 34 File::~File() 35 { 36 } 37 38 39 status_t 40 File::InitCheck() 41 { 42 return fStream.InitCheck(); 43 } 44 45 46 ssize_t 47 File::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) 48 { 49 status_t status = fStream.ReadAt(pos, (uint8 *)buffer, &bufferSize); 50 if (status < B_OK) 51 return status; 52 53 return bufferSize; 54 } 55 56 57 ssize_t 58 File::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize) 59 { 60 return EROFS; 61 } 62 63 64 status_t 65 File::GetName(char *nameBuffer, size_t bufferSize) const 66 { 67 return fStream.GetName(nameBuffer, bufferSize); 68 } 69 70 71 int32 72 File::Type() const 73 { 74 return S_IFREG; 75 } 76 77 78 off_t 79 File::Size() const 80 { 81 return fStream.Size(); 82 } 83 84 85 ino_t 86 File::Inode() const 87 { 88 return fStream.ID(); 89 } 90 91 92 } // namespace BFS 93