Restore the "GPL licensing not permitted" in GLUT license headers.
[haiku.git] / headers / os / storage / Directory.h
blob91bdb3bd78bda05f61466ba138ce2222a336f48c
1 /*
2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _DIRECTORY_H
6 #define _DIRECTORY_H
9 #include <Node.h>
10 #include <EntryList.h>
11 #include <StorageDefs.h>
14 class BFile;
15 class BSymLink;
16 struct stat_beos;
19 class BDirectory : public BNode, public BEntryList {
20 public:
21 BDirectory();
22 BDirectory(const BDirectory &dir);
23 BDirectory(const entry_ref *ref);
24 BDirectory(const node_ref *nref);
25 BDirectory(const BEntry *entry);
26 BDirectory(const char *path);
27 BDirectory(const BDirectory *dir, const char *path);
29 virtual ~BDirectory();
31 status_t SetTo(const entry_ref *ref);
32 status_t SetTo(const node_ref *nref);
33 status_t SetTo(const BEntry *entry);
34 status_t SetTo(const char *path);
35 status_t SetTo(const BDirectory *dir, const char *path);
37 status_t GetEntry(BEntry *entry) const;
39 bool IsRootDirectory() const;
41 status_t FindEntry(const char *path, BEntry *entry,
42 bool traverse = false) const;
44 bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const;
45 bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const;
47 status_t GetStatFor(const char *path, struct stat *st) const;
49 virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
50 virtual status_t GetNextRef(entry_ref *ref);
51 virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
52 int32 count = INT_MAX);
53 virtual status_t Rewind();
54 virtual int32 CountEntries();
56 status_t CreateDirectory(const char *path, BDirectory *dir);
57 status_t CreateFile(const char *path, BFile *file,
58 bool failIfExists = false);
59 status_t CreateSymLink(const char *path, const char *linkToPath,
60 BSymLink *link);
62 BDirectory &operator=(const BDirectory &dir);
64 private:
65 friend class BNode;
66 friend class BEntry;
67 friend class BFile;
69 status_t _GetStatFor(const char *path, struct stat *st) const;
70 status_t _GetStatFor(const char *path, struct stat_beos *st) const;
72 virtual void _ErectorDirectory1();
73 virtual void _ErectorDirectory2();
74 virtual void _ErectorDirectory3();
75 virtual void _ErectorDirectory4();
76 virtual void _ErectorDirectory5();
77 virtual void _ErectorDirectory6();
79 private:
80 virtual void close_fd();
81 int get_fd() const;
83 private:
84 uint32 _reservedData[7];
85 int fDirFd;
88 status_t create_directory(const char *path, mode_t mode);
90 #endif // _DIRECTORY_H