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