1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 //--------------------------------------------------------------------- 5 /*! 6 \file Directory.h 7 BDirectory interface declaration. 8 */ 9 10 #ifndef _DIRECTORY_H 11 #define _DIRECTORY_H 12 13 #include <Node.h> 14 #include <EntryList.h> 15 #include <StorageDefs.h> 16 #include <StorageDefs.Private.h> 17 18 #ifdef USE_OPENBEOS_NAMESPACE 19 namespace OpenBeOS { 20 #endif 21 22 class BSymLink; 23 24 /*! 25 \class BDirectory 26 \brief A directory in the filesystem 27 28 Provides an interface for manipulating directories and their contents. 29 30 \author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a> 31 \author <a href="mailto:tylerdauwalder@users.sf.net">Tyler Dauwalder</a> 32 33 \version 0.0.0 34 */ 35 class BDirectory : public BNode, public BEntryList { 36 public: 37 BDirectory(); 38 BDirectory(const BDirectory &dir); 39 BDirectory(const entry_ref *ref); 40 BDirectory(const node_ref *nref); 41 BDirectory(const BEntry *entry); 42 BDirectory(const char *path); 43 BDirectory(const BDirectory *dir, const char *path); 44 45 virtual ~BDirectory(); 46 47 status_t SetTo(const entry_ref *ref); 48 status_t SetTo(const node_ref *nref); 49 status_t SetTo(const BEntry *entry); 50 status_t SetTo(const char *path); 51 status_t SetTo(const BDirectory *dir, const char *path); 52 53 status_t GetEntry(BEntry *entry) const; 54 55 status_t FindEntry(const char *path, BEntry *entry, 56 bool traverse = false) const; 57 58 bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const; 59 bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const; 60 61 status_t GetStatFor(const char *path, struct stat *st) const; 62 63 virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); 64 virtual status_t GetNextRef(entry_ref *ref); 65 virtual int32 GetNextDirents(dirent *buf, size_t bufSize, 66 int32 count = INT_MAX); 67 virtual status_t Rewind(); 68 virtual int32 CountEntries(); 69 70 status_t CreateDirectory(const char *path, BDirectory *dir); 71 status_t CreateFile(const char *path, BFile *file, 72 bool failIfExists = false); 73 status_t CreateSymLink(const char *path, const char *linkToPath, 74 BSymLink *link); 75 76 BDirectory &operator=(const BDirectory &dir); 77 78 private: 79 friend class BNode; 80 81 virtual void _ErectorDirectory1(); 82 virtual void _ErectorDirectory2(); 83 virtual void _ErectorDirectory3(); 84 virtual void _ErectorDirectory4(); 85 virtual void _ErectorDirectory5(); 86 virtual void _ErectorDirectory6(); 87 88 private: 89 virtual void close_fd(); 90 int get_fd() const; 91 92 status_t set_dir_fd(int fd); 93 94 private: 95 uint32 _reservedData[7]; 96 int fDirFd; 97 node_ref fDirNodeRef; 98 99 friend class BEntry; 100 friend class BFile; 101 }; 102 103 104 // C functions 105 106 status_t create_directory(const char *path, mode_t mode); 107 108 109 #ifdef USE_OPENBEOS_NAMESPACE 110 }; // namespace OpenBeOS 111 #endif 112 113 #endif // _DIRECTORY_H 114 115 116