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