Restore the "GPL licensing not permitted" in GLUT license headers.
[haiku.git] / headers / build / os / storage / Entry.h
blob179ab0f575234e73bbd21057fea5e2396124e6d7
1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
3 // by the MIT License.
4 //---------------------------------------------------------------------
5 /*!
6 \file Entry.h
7 BEntry and entry_ref interface declarations.
8 */
9 #ifndef _ENTRY_H
10 #define _ENTRY_H
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <SupportDefs.h>
16 #include <Statable.h>
18 #ifdef USE_OPENBEOS_NAMESPACE
19 namespace OpenBeOS {
20 #endif
22 class BDirectory;
23 class BPath;
25 struct entry_ref {
26 entry_ref();
27 entry_ref(dev_t dev, ino_t dir, const char *name);
28 entry_ref(const entry_ref &ref);
29 ~entry_ref();
31 status_t set_name(const char *name);
33 bool operator==(const entry_ref &ref) const;
34 bool operator!=(const entry_ref &ref) const;
35 entry_ref &operator=(const entry_ref &ref);
37 dev_t device;
38 ino_t directory;
39 char *name;
42 class BEntry : public BStatable {
43 public:
44 BEntry();
45 BEntry(const BDirectory *dir, const char *path, bool traverse = false);
46 BEntry(const entry_ref *ref, bool traverse = false);
47 BEntry(const char *path, bool traverse = false);
48 BEntry(const BEntry &entry);
49 virtual ~BEntry();
51 status_t InitCheck() const;
52 bool Exists() const;
54 const char* Name() const;
56 virtual status_t GetStat(struct stat *st) const;
58 status_t SetTo(const BDirectory *dir, const char *path,
59 bool traverse = false);
60 status_t SetTo(const entry_ref *ref, bool traverse = false);
61 status_t SetTo(const char *path, bool traverse = false);
62 void Unset();
64 status_t GetRef(entry_ref *ref) const;
65 status_t GetPath(BPath *path) const;
66 status_t GetParent(BEntry *entry) const;
67 status_t GetParent(BDirectory *dir) const;
68 status_t GetName(char *buffer) const;
70 status_t Rename(const char *path, bool clobber = false);
71 status_t MoveTo(BDirectory *dir, const char *path = NULL,
72 bool clobber = false);
73 status_t Remove();
75 bool operator==(const BEntry &item) const;
76 bool operator!=(const BEntry &item) const;
78 BEntry &operator=(const BEntry &item);
80 private:
81 friend class BDirectory;
82 friend class BFile;
83 friend class BNode;
84 friend class BSymLink;
86 virtual void _PennyEntry1();
87 virtual void _PennyEntry2();
88 virtual void _PennyEntry3();
89 virtual void _PennyEntry4();
90 virtual void _PennyEntry5();
91 virtual void _PennyEntry6();
93 /*! Currently unused. */
94 uint32 _pennyData[4];
96 /*! BEntry implementation of BStatable::set_stat() */
97 virtual status_t set_stat(struct stat &st, uint32 what);
99 status_t set(int dir, const char *path, bool traverse);
101 /*! File descriptor for the entry's parent directory. */
102 int fDirFd;
104 /*! Leaf name of the entry. */
105 char *fName;
107 /*! The object's initialization status. */
108 status_t fCStatus;
110 status_t set_name(const char *name);
112 status_t _Rename(BEntry& target, bool clobber);
114 void Dump(const char *name = NULL);
117 // C functions
119 status_t get_ref_for_path(const char *path, entry_ref *ref);
120 bool operator<(const entry_ref &a, const entry_ref &b);
123 #ifdef USE_OPENBEOS_NAMESPACE
124 }; // namespace OpenBeOS
125 #endif
127 #endif // _ENTRY_H