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 bool IsRootDirectory() const; 56 57 status_t FindEntry(const char *path, BEntry *entry, 58 bool traverse = false) const; 59 60 bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const; 61 bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const; 62 63 status_t GetStatFor(const char *path, struct stat *st) const; 64 65 virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); 66 virtual status_t GetNextRef(entry_ref *ref); 67 virtual int32 GetNextDirents(dirent *buf, size_t bufSize, 68 int32 count = INT_MAX); 69 virtual status_t Rewind(); 70 virtual int32 CountEntries(); 71 72 status_t CreateDirectory(const char *path, BDirectory *dir); 73 status_t CreateFile(const char *path, BFile *file, 74 bool failIfExists = false); 75 status_t CreateSymLink(const char *path, const char *linkToPath, 76 BSymLink *link); 77 78 BDirectory &operator=(const BDirectory &dir); 79 80 private: 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 BPrivate::Storage::FileDescriptor get_fd() const; 91 92 private: 93 uint32 _reservedData[7]; 94 BPrivate::Storage::FileDescriptor fDirFd; 95 96 friend class BEntry; 97 }; 98 99 100 // C functions 101 102 status_t create_directory(const char *path, mode_t mode); 103 104 105 #ifdef USE_OPENBEOS_NAMESPACE 106 }; // namespace OpenBeOS 107 #endif 108 109 #endif // _DIRECTORY_H 110 111 112