1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 //--------------------------------------------------------------------- 5 /*! 6 \file Path.h 7 BPath interface declaration. 8 */ 9 10 #ifndef _PATH_H 11 #define _PATH_H 12 13 #include <Flattenable.h> 14 #include <StorageDefs.h> 15 #include <Message.h> /* for convenience, as in R5 */ 16 17 #ifdef USE_OPENBEOS_NAMESPACE 18 namespace OpenBeOS { 19 #endif 20 21 // Forward declarations 22 class BDirectory; 23 class BEntry; 24 struct entry_ref; 25 26 /*! 27 \class BPath 28 \brief An absolute pathname wrapper class 29 30 Provides a convenient means of managing pathnames. 31 32 \author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a> 33 \author <a href="mailto:tylerdauwalder@users.sf.net">Tyler Dauwalder</a> 34 35 \version 0.0.0 36 */ 37 class BPath : public BFlattenable { 38 public: 39 40 BPath(); 41 BPath(const BPath &path); 42 BPath(const entry_ref *ref); 43 BPath(const BEntry *entry); 44 BPath(const char *dir, const char *leaf = NULL, bool normalize = false); 45 BPath(const BDirectory *dir, const char *leaf, bool normalize = false); 46 47 virtual ~BPath(); 48 49 status_t InitCheck() const; 50 51 status_t SetTo(const entry_ref *ref); 52 status_t SetTo(const BEntry *entry); 53 status_t SetTo(const char *path, const char *leaf = NULL, 54 bool normalize = false); 55 status_t SetTo(const BDirectory *dir, const char *path, 56 bool normalize = false); 57 void Unset(); 58 59 status_t Append(const char *path, bool normalize = false); 60 61 const char *Path() const; 62 const char *Leaf() const; 63 status_t GetParent(BPath *path) const; 64 65 bool operator==(const BPath &item) const; 66 bool operator==(const char *path) const; 67 bool operator!=(const BPath &item) const; 68 bool operator!=(const char *path) const; 69 BPath& operator=(const BPath &item); 70 BPath& operator=(const char *path); 71 72 // BFlattenable protocol 73 virtual bool IsFixedSize() const; 74 virtual type_code TypeCode() const; 75 virtual ssize_t FlattenedSize() const; 76 virtual status_t Flatten(void *buffer, ssize_t size) const; 77 virtual bool AllowsTypeCode(type_code code) const; 78 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 79 80 private: 81 virtual void _WarPath1(); 82 virtual void _WarPath2(); 83 virtual void _WarPath3(); 84 85 uint32 _warData[4]; 86 87 char *fName; 88 status_t fCStatus; 89 90 class EBadInput { }; 91 92 status_t set_path(const char *path); 93 94 static bool MustNormalize(const char *path); 95 }; 96 97 #ifdef USE_OPENBEOS_NAMESPACE 98 }; // namespace OpenBeOS 99 #endif 100 101 #endif // _PATH_H 102 103 104