1 /* 2 * Copyright 2004-2006, Ingo Weinhold, bonefish@users.sf.net. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _K_PATH_H 6 #define _K_PATH_H 7 8 9 #include <KernelExport.h> 10 11 12 namespace BPrivate { 13 namespace DiskDevice { 14 15 class KPath { 16 public: 17 KPath(size_t bufferSize = B_PATH_NAME_LENGTH); 18 KPath(const char* path, bool normalize = false, 19 size_t bufferSize = B_PATH_NAME_LENGTH); 20 KPath(const KPath& other); 21 ~KPath(); 22 23 status_t SetTo(const char *path, bool normalize = false, 24 size_t bufferSize = B_PATH_NAME_LENGTH); 25 26 status_t InitCheck() const; 27 28 status_t SetPath(const char *path, bool normalize = false); 29 const char *Path() const; 30 size_t Length() const { return fPathLength; } 31 32 size_t BufferSize() const { return fBufferSize; } 33 char *LockBuffer(); 34 void UnlockBuffer(); 35 36 const char *Leaf() const; 37 status_t ReplaceLeaf(const char *newLeaf); 38 bool RemoveLeaf(); 39 // returns false, if nothing could be removed anymore 40 41 status_t Append(const char *toAppend, bool isComponent = true); 42 43 KPath& operator=(const KPath& other); 44 KPath& operator=(const char* path); 45 46 bool operator==(const KPath& other) const; 47 bool operator==(const char* path) const; 48 bool operator!=(const KPath& other) const; 49 bool operator!=(const char* path) const; 50 51 private: 52 void _ChopTrailingSlashes(); 53 54 char* fBuffer; 55 size_t fBufferSize; 56 size_t fPathLength; 57 bool fLocked; 58 }; 59 60 } // namespace DiskDevice 61 } // namespace BPrivate 62 63 using BPrivate::DiskDevice::KPath; 64 65 #endif /* _K_PATH_H */ 66