1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
4 //---------------------------------------------------------------------
7 BFile interface declaration.
15 #include <StorageDefs.h>
20 \brief BFile is a wrapper class for common operations on files providing
21 access to the file's content data and its attributes.
23 A BFile represents a file in some file system. It implements the
24 BPositionIO interface and thus the methods to read from and write to the
25 file, and is derived of BNode to provide access to the file's attributes.
27 \author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
31 class BFile
: public BNode
, public BPositionIO
{
34 BFile(const BFile
&file
);
35 BFile(const entry_ref
*ref
, uint32 openMode
);
36 BFile(const BEntry
*entry
, uint32 openMode
);
37 BFile(const char *path
, uint32 openMode
);
38 BFile(const BDirectory
*dir
, const char *path
, uint32 openMode
);
41 status_t
SetTo(const entry_ref
*ref
, uint32 openMode
);
42 status_t
SetTo(const BEntry
*entry
, uint32 openMode
);
43 status_t
SetTo(const char *path
, uint32 openMode
);
44 status_t
SetTo(const BDirectory
*dir
, const char *path
, uint32 openMode
);
46 bool IsReadable() const;
47 bool IsWritable() const;
49 virtual ssize_t
Read(void *buffer
, size_t size
);
50 virtual ssize_t
ReadAt(off_t location
, void *buffer
, size_t size
);
51 virtual ssize_t
Write(const void *buffer
, size_t size
);
52 virtual ssize_t
WriteAt(off_t location
, const void *buffer
, size_t size
);
54 virtual off_t
Seek(off_t offset
, uint32 seekMode
);
55 virtual off_t
Position() const;
57 virtual status_t
SetSize(off_t size
);
58 virtual status_t
GetSize(off_t
* size
) const;
60 BFile
&operator=(const BFile
&file
);
63 virtual void _PhiloFile1();
64 virtual void _PhiloFile2();
65 virtual void _PhiloFile3();
66 virtual void _PhiloFile4();
67 virtual void _PhiloFile5();
68 virtual void _PhiloFile6();
70 uint32 _reservedData
[8];
74 virtual void close_fd();
77 //! The file's open mode.