2006-06-21 17:49:16 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-08-12 11:24:02 +04:00
|
|
|
#ifndef _FILE_H
|
|
|
|
#define _FILE_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2006-06-21 17:49:16 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <DataIO.h>
|
|
|
|
#include <Node.h>
|
2008-01-20 17:44:02 +03:00
|
|
|
#include <StorageDefs.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2007-10-16 02:35:52 +04:00
|
|
|
class BEntry;
|
|
|
|
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
class BFile : public BNode, public BPositionIO {
|
2006-06-21 17:49:16 +04:00
|
|
|
public:
|
|
|
|
BFile();
|
|
|
|
BFile(const BFile &file);
|
|
|
|
BFile(const entry_ref *ref, uint32 openMode);
|
|
|
|
BFile(const BEntry *entry, uint32 openMode);
|
|
|
|
BFile(const char *path, uint32 openMode);
|
|
|
|
BFile(const BDirectory *dir, const char *path, uint32 openMode);
|
|
|
|
virtual ~BFile();
|
|
|
|
|
|
|
|
status_t SetTo(const entry_ref *ref, uint32 openMode);
|
|
|
|
status_t SetTo(const BEntry *entry, uint32 openMode);
|
|
|
|
status_t SetTo(const char *path, uint32 openMode);
|
|
|
|
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
|
|
|
|
|
|
|
|
bool IsReadable() const;
|
|
|
|
bool IsWritable() const;
|
|
|
|
|
|
|
|
virtual ssize_t Read(void *buffer, size_t size);
|
|
|
|
virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
|
|
|
|
virtual ssize_t Write(const void *buffer, size_t size);
|
|
|
|
virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
|
|
|
|
|
|
|
|
virtual off_t Seek(off_t offset, uint32 seekMode);
|
|
|
|
virtual off_t Position() const;
|
|
|
|
|
|
|
|
virtual status_t SetSize(off_t size);
|
|
|
|
virtual status_t GetSize(off_t* size) const;
|
|
|
|
|
|
|
|
BFile &operator=(const BFile &file);
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void _PhiloFile1();
|
|
|
|
virtual void _PhiloFile2();
|
|
|
|
virtual void _PhiloFile3();
|
|
|
|
virtual void _PhiloFile4();
|
|
|
|
virtual void _PhiloFile5();
|
|
|
|
virtual void _PhiloFile6();
|
|
|
|
|
|
|
|
uint32 _reservedData[8];
|
|
|
|
|
|
|
|
private:
|
|
|
|
int get_fd() const;
|
|
|
|
virtual void close_fd();
|
|
|
|
|
|
|
|
private:
|
|
|
|
//! The file's open mode.
|
|
|
|
uint32 fMode;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2002-08-12 11:24:02 +04:00
|
|
|
#endif // _FILE_H
|