xref: /haiku/src/system/boot/loader/file_systems/bfs/File.cpp (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
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 
12 namespace BFS {
13 
14 File::File(Volume &volume, block_run run)
15 	:
16 	fStream(volume, run)
17 {
18 }
19 
20 
21 File::File(Volume &volume, off_t id)
22 	:
23 	fStream(volume, id)
24 {
25 }
26 
27 
28 File::File(const Stream &stream)
29 	:
30 	fStream(stream)
31 {
32 }
33 
34 
35 File::~File()
36 {
37 }
38 
39 
40 status_t
41 File::InitCheck()
42 {
43 	return fStream.InitCheck();
44 }
45 
46 
47 ssize_t
48 File::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 
58 ssize_t
59 File::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
60 {
61 	return EROFS;
62 }
63 
64 
65 status_t
66 File::GetName(char *nameBuffer, size_t bufferSize) const
67 {
68 	return fStream.GetName(nameBuffer, bufferSize);
69 }
70 
71 
72 int32
73 File::Type() const
74 {
75 	return S_IFREG;
76 }
77 
78 
79 off_t
80 File::Size() const
81 {
82 	return fStream.Size();
83 }
84 
85 
86 ino_t
87 File::Inode() const
88 {
89 	return fStream.ID();
90 }
91 
92 }	// namespace BFS
93