Add a simple Node implementation for BFS files (and everything else that
needs access to the stream directly). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4654 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
|
||||
|
||||
#include "File.h"
|
||||
|
||||
|
||||
namespace BFS {
|
||||
|
||||
File::File(Volume &volume, block_run run)
|
||||
:
|
||||
fStream(volume, run)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File::File(Volume &volume, off_t id)
|
||||
:
|
||||
fStream(volume, id)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File::File(const Stream &stream)
|
||||
:
|
||||
fStream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File::~File()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
File::InitCheck()
|
||||
{
|
||||
return fStream.InitCheck();
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
File::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
|
||||
{
|
||||
return fStream.ReadAt(pos, (uint8 *)buffer, &bufferSize);
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
File::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
|
||||
{
|
||||
return EROFS;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
File::GetName(char *nameBuffer, size_t bufferSize) const
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
File::Type() const
|
||||
{
|
||||
return S_IFREG;
|
||||
}
|
||||
|
||||
|
||||
off_t
|
||||
File::Size() const
|
||||
{
|
||||
return fStream.Size();
|
||||
}
|
||||
|
||||
} // namespace BFS
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
#ifndef FILE_H
|
||||
#define FILE_H
|
||||
|
||||
|
||||
#include <boot/vfs.h>
|
||||
|
||||
#include "Volume.h"
|
||||
#include "Stream.h"
|
||||
|
||||
|
||||
namespace BFS {
|
||||
|
||||
class File : public Node {
|
||||
public:
|
||||
File(Volume &volume, block_run run);
|
||||
File(Volume &volume, off_t id);
|
||||
File(const Stream &stream);
|
||||
virtual ~File();
|
||||
|
||||
status_t InitCheck();
|
||||
|
||||
virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize);
|
||||
virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize);
|
||||
|
||||
virtual status_t GetName(char *nameBuffer, size_t bufferSize) const;
|
||||
virtual int32 Type() const;
|
||||
virtual off_t Size() const;
|
||||
|
||||
private:
|
||||
Stream fStream;
|
||||
};
|
||||
|
||||
} // namespace BFS
|
||||
|
||||
#endif /* FILE_H */
|
||||
Reference in New Issue
Block a user