2009-05-25 18:03:38 +04:00
|
|
|
/*
|
2012-11-13 02:49:38 +04:00
|
|
|
* Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
|
2009-05-25 18:03:38 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-08-12 11:24:02 +04:00
|
|
|
#ifndef _ENTRY_H
|
|
|
|
#define _ENTRY_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
#include <Statable.h>
|
|
|
|
|
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
class BDirectory;
|
|
|
|
class BPath;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
struct entry_ref {
|
2009-12-18 18:05:37 +03:00
|
|
|
entry_ref();
|
|
|
|
entry_ref(dev_t dev, ino_t dir,
|
|
|
|
const char* name);
|
|
|
|
entry_ref(const entry_ref& ref);
|
|
|
|
~entry_ref();
|
2009-05-25 18:03:38 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
status_t set_name(const char* name);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
bool operator==(const entry_ref& ref) const;
|
|
|
|
bool operator!=(const entry_ref& ref) const;
|
|
|
|
entry_ref& operator=(const entry_ref& ref);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
dev_t device;
|
|
|
|
ino_t directory;
|
|
|
|
char* name;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
class BEntry : public BStatable {
|
|
|
|
public:
|
2009-12-18 18:05:37 +03:00
|
|
|
BEntry();
|
|
|
|
BEntry(const BDirectory* dir, const char* path,
|
|
|
|
bool traverse = false);
|
|
|
|
BEntry(const entry_ref* ref,
|
|
|
|
bool traverse = false);
|
|
|
|
BEntry(const char* path, bool traverse = false);
|
|
|
|
BEntry(const BEntry& entry);
|
|
|
|
virtual ~BEntry();
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
bool Exists() const;
|
|
|
|
|
2012-11-13 02:49:38 +04:00
|
|
|
const char* Name() const;
|
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
virtual status_t GetStat(struct stat* stat) const;
|
|
|
|
|
|
|
|
status_t SetTo(const BDirectory* dir, const char* path,
|
|
|
|
bool traverse = false);
|
|
|
|
status_t SetTo(const entry_ref* ref,
|
|
|
|
bool traverse = false);
|
|
|
|
status_t SetTo(const char* path, bool traverse = false);
|
|
|
|
void Unset();
|
|
|
|
|
2010-02-20 00:31:59 +03:00
|
|
|
status_t GetRef(entry_ref* ref) const;
|
|
|
|
status_t GetPath(BPath* path) const;
|
|
|
|
status_t GetParent(BEntry* entry) const;
|
|
|
|
status_t GetParent(BDirectory* dir) const;
|
|
|
|
status_t GetName(char* buffer) const;
|
2009-12-18 18:05:37 +03:00
|
|
|
|
2010-02-20 00:31:59 +03:00
|
|
|
status_t Rename(const char* path, bool clobber = false);
|
|
|
|
status_t MoveTo(BDirectory* dir, const char* path = NULL,
|
|
|
|
bool clobber = false);
|
|
|
|
status_t Remove();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2010-02-20 00:31:59 +03:00
|
|
|
bool operator==(const BEntry& item) const;
|
|
|
|
bool operator!=(const BEntry& item) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2010-02-20 00:31:59 +03:00
|
|
|
BEntry& operator=(const BEntry& item);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2009-12-18 18:05:37 +03:00
|
|
|
friend class BDirectory;
|
|
|
|
friend class BFile;
|
|
|
|
friend class BNode;
|
|
|
|
friend class BSymLink;
|
|
|
|
|
|
|
|
virtual void _PennyEntry1();
|
|
|
|
virtual void _PennyEntry2();
|
|
|
|
virtual void _PennyEntry3();
|
|
|
|
virtual void _PennyEntry4();
|
|
|
|
virtual void _PennyEntry5();
|
|
|
|
virtual void _PennyEntry6();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2011-12-19 06:28:55 +04:00
|
|
|
// BEntry implementation of BStatable::set_stat()
|
2009-12-18 18:05:37 +03:00
|
|
|
virtual status_t set_stat(struct stat& stat, uint32 what);
|
|
|
|
status_t _SetTo(int dir, const char* path,
|
|
|
|
bool traverse);
|
|
|
|
status_t _SetName(const char* name);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
status_t _Rename(BEntry& target, bool clobber);
|
2009-05-25 18:03:38 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
void _Dump(const char* name = NULL);
|
2009-05-25 18:03:38 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
status_t _GetStat(struct stat* stat) const;
|
|
|
|
virtual status_t _GetStat(struct stat_beos* stat) const;
|
2009-05-25 18:03:38 +04:00
|
|
|
|
|
|
|
private:
|
2009-12-18 18:05:37 +03:00
|
|
|
int fDirFd;
|
|
|
|
char* fName;
|
|
|
|
status_t fCStatus;
|
2009-05-25 18:03:38 +04:00
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
uint32 _reserved[4];
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-18 18:05:37 +03:00
|
|
|
status_t get_ref_for_path(const char* path, entry_ref* ref);
|
|
|
|
bool operator<(const entry_ref& a, const entry_ref& b);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2002-08-12 11:24:02 +04:00
|
|
|
#endif // _ENTRY_H
|