1 // KPath.h 2 // 3 // A simple class wrapping a path. Has a fixed-sized buffer. 4 5 #ifndef _K_PATH_H 6 #define _K_PATH_H 7 8 #include <KernelExport.h> 9 10 namespace BPrivate { 11 namespace DiskDevice { 12 13 class KPath { 14 public: 15 KPath(int32 bufferSize = B_PATH_NAME_LENGTH); 16 KPath(const char* path, bool normalize = false, 17 int32 bufferSize = B_PATH_NAME_LENGTH); 18 KPath(const KPath& other); 19 ~KPath(); 20 21 status_t SetTo(const char *path, bool normalize = false, 22 int32 bufferSize = B_PATH_NAME_LENGTH); 23 24 status_t InitCheck() const; 25 26 status_t SetPath(const char *path, bool normalize = false); 27 const char *Path() const; 28 int32 Length() const; 29 30 int32 BufferSize() const; 31 char *LockBuffer(); 32 void UnlockBuffer(); 33 34 const char *Leaf() const; 35 status_t ReplaceLeaf(const char *newLeaf); 36 37 status_t Append(const char *toAppend, bool isComponent = true); 38 39 KPath& operator=(const KPath& other); 40 KPath& operator=(const char* path); 41 42 bool operator==(const KPath& other) const; 43 bool operator==(const char* path) const; 44 bool operator!=(const KPath& other) const; 45 bool operator!=(const char* path) const; 46 47 private: 48 void _ChopTrailingSlashes(); 49 50 char* fBuffer; 51 int32 fBufferSize; 52 int32 fPathLength; 53 bool fLocked; 54 }; 55 56 } // namespace DiskDevice 57 } // namespace BPrivate 58 59 using BPrivate::DiskDevice::KPath; 60 61 #endif /* _K_PATH_H */ 62