* Class behaviour is platform-dependent. * It uses platform-dependent separators for path-reconstructing operations. */
| 20 | * It uses platform-dependent separators for path-reconstructing operations. |
| 21 | */ |
| 22 | class TFsPath { |
| 23 | private: |
| 24 | struct TSplit; |
| 25 | |
| 26 | public: |
| 27 | TFsPath(); |
| 28 | TFsPath(const TString& path); |
| 29 | TFsPath(const TStringBuf path); |
| 30 | TFsPath(const char* path); |
| 31 | |
| 32 | TFsPath(const std::string& path) |
| 33 | : TFsPath(TStringBuf(path)) |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | TFsPath(const TFsPath& that); |
| 38 | TFsPath(TFsPath&& that); |
| 39 | |
| 40 | TFsPath& operator=(const TFsPath& that); |
| 41 | TFsPath& operator=(TFsPath&& that); |
| 42 | |
| 43 | ~TFsPath() = default; |
| 44 | |
| 45 | void CheckDefined() const; |
| 46 | |
| 47 | inline bool IsDefined() const { |
| 48 | return Path_.length() > 0; |
| 49 | } |
| 50 | |
| 51 | inline explicit operator bool() const { |
| 52 | return IsDefined(); |
| 53 | } |
| 54 | |
| 55 | inline const char* c_str() const { |
| 56 | return Path_.c_str(); |
| 57 | } |
| 58 | |
| 59 | inline operator const TString&() const { |
| 60 | return Path_; |
| 61 | } |
| 62 | |
| 63 | inline bool operator==(const TFsPath& that) const { |
| 64 | return Path_ == that.Path_; |
| 65 | } |
| 66 | |
| 67 | TFsPath& operator/=(const TFsPath& that); |
| 68 | |
| 69 | friend TFsPath operator/(const TFsPath& s, const TFsPath& p) { |
| 70 | TFsPath ret(s); |
| 71 | return ret /= p; |
| 72 | } |
| 73 | |
| 74 | const TPathSplit& PathSplit() const; |
| 75 | |
| 76 | TFsPath& Fix(); |
| 77 | |
| 78 | inline const TString& GetPath() const { |
| 79 | return Path_; |