2007-07-05 03:20:05 +04:00
|
|
|
/*
|
2011-11-06 12:23:41 +04:00
|
|
|
* Copyright 2002-2011, Haiku, Inc. All Rights Reserved.
|
2007-07-05 03:20:05 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-08-12 11:24:02 +04:00
|
|
|
#ifndef _NODE_H
|
|
|
|
#define _NODE_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2011-11-06 12:23:41 +04:00
|
|
|
|
2007-07-05 03:20:05 +04:00
|
|
|
#include <Statable.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-05-25 18:03:38 +04:00
|
|
|
|
2007-07-05 03:20:05 +04:00
|
|
|
class BDirectory;
|
2007-10-16 02:35:52 +04:00
|
|
|
class BEntry;
|
2007-10-16 00:13:55 +04:00
|
|
|
class BString;
|
|
|
|
struct entry_ref;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
struct node_ref {
|
2009-05-25 18:03:38 +04:00
|
|
|
node_ref();
|
2013-04-07 01:30:18 +04:00
|
|
|
node_ref(dev_t device, ino_t node);
|
2002-07-09 16:24:59 +04:00
|
|
|
node_ref(const node_ref &ref);
|
2007-07-05 03:20:05 +04:00
|
|
|
|
2011-11-06 12:23:41 +04:00
|
|
|
bool operator==(const node_ref& ref) const;
|
|
|
|
bool operator!=(const node_ref& ref) const;
|
2013-08-06 02:39:13 +04:00
|
|
|
bool operator<(const node_ref& ref) const;
|
2011-11-06 12:23:41 +04:00
|
|
|
node_ref& operator=(const node_ref& ref);
|
2007-07-05 03:20:05 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
dev_t device;
|
|
|
|
ino_t node;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BNode : public BStatable {
|
|
|
|
public:
|
2011-11-06 12:23:41 +04:00
|
|
|
BNode();
|
|
|
|
BNode(const entry_ref* ref);
|
|
|
|
BNode(const BEntry* entry);
|
|
|
|
BNode(const char* path);
|
|
|
|
BNode(const BDirectory* dir, const char* path);
|
|
|
|
BNode(const BNode& node);
|
|
|
|
virtual ~BNode();
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
|
|
|
|
virtual status_t GetStat(struct stat* st) const;
|
|
|
|
|
|
|
|
status_t SetTo(const entry_ref* ref);
|
|
|
|
status_t SetTo(const BEntry* entry);
|
|
|
|
status_t SetTo(const char* path);
|
|
|
|
status_t SetTo(const BDirectory* dir, const char* path);
|
|
|
|
void Unset();
|
|
|
|
|
|
|
|
status_t Lock();
|
|
|
|
status_t Unlock();
|
|
|
|
|
|
|
|
status_t Sync();
|
|
|
|
|
|
|
|
ssize_t WriteAttr(const char* name, type_code type,
|
|
|
|
off_t offset, const void* buffer,
|
|
|
|
size_t length);
|
|
|
|
ssize_t ReadAttr(const char* name, type_code type,
|
|
|
|
off_t offset, void* buffer,
|
|
|
|
size_t length) const;
|
|
|
|
status_t RemoveAttr(const char* name);
|
|
|
|
status_t RenameAttr(const char* oldName,
|
|
|
|
const char* newName);
|
|
|
|
status_t GetAttrInfo(const char* name,
|
|
|
|
struct attr_info* info) const;
|
|
|
|
status_t GetNextAttrName(char* buffer);
|
|
|
|
status_t RewindAttrs();
|
|
|
|
status_t WriteAttrString(const char* name,
|
|
|
|
const BString* data);
|
|
|
|
status_t ReadAttrString(const char* name,
|
|
|
|
BString* result) const;
|
|
|
|
|
|
|
|
BNode& operator=(const BNode& node);
|
|
|
|
bool operator==(const BNode& node) const;
|
|
|
|
bool operator!=(const BNode& node) const;
|
|
|
|
|
|
|
|
int Dup();
|
|
|
|
// This should be "const" but R5's is not... Ugggh.
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BFile;
|
|
|
|
friend class BDirectory;
|
|
|
|
friend class BSymLink;
|
|
|
|
|
2011-11-06 12:23:41 +04:00
|
|
|
virtual void _RudeNode1();
|
|
|
|
virtual void _RudeNode2();
|
|
|
|
virtual void _RudeNode3();
|
|
|
|
virtual void _RudeNode4();
|
|
|
|
virtual void _RudeNode5();
|
|
|
|
virtual void _RudeNode6();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2011-11-06 12:23:41 +04:00
|
|
|
status_t set_fd(int fd);
|
|
|
|
virtual void close_fd();
|
|
|
|
void set_status(status_t newStatus);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2011-11-06 12:23:41 +04:00
|
|
|
status_t _SetTo(int fd, const char* path, bool traverse);
|
|
|
|
status_t _SetTo(const entry_ref* ref, bool traverse);
|
2004-08-29 00:14:46 +04:00
|
|
|
|
2011-11-06 12:23:41 +04:00
|
|
|
virtual status_t set_stat(struct stat& st, uint32 what);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2011-11-06 12:23:41 +04:00
|
|
|
status_t _GetStat(struct stat* st) const;
|
|
|
|
virtual status_t _GetStat(struct stat_beos* st) const;
|
|
|
|
status_t InitAttrDir();
|
2009-05-25 18:03:38 +04:00
|
|
|
|
|
|
|
private:
|
2011-11-06 12:23:41 +04:00
|
|
|
uint32 rudeData[4];
|
|
|
|
int fFd;
|
|
|
|
int fAttrFd;
|
|
|
|
status_t fCStatus;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2011-11-06 12:23:41 +04:00
|
|
|
|
2002-08-12 11:24:02 +04:00
|
|
|
#endif // _NODE_H
|