diff --git a/headers/os/storage/Path.h b/headers/os/storage/Path.h index 13438a40f9..d12723afc3 100644 --- a/headers/os/storage/Path.h +++ b/headers/os/storage/Path.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2012, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _PATH_H @@ -25,7 +25,7 @@ public: BPath(const BEntry* entry); BPath(const char* dir, const char* leaf = NULL, bool normalize = false); - BPath(const BDirectory* dir, + BPath(const BDirectory* dir, const char* leaf = NULL, bool normalize = false); @@ -37,7 +37,7 @@ public: status_t SetTo(const BEntry* entry); status_t SetTo(const char* path, const char* leaf = NULL, bool normalize = false); - status_t SetTo(const BDirectory* dir, + status_t SetTo(const BDirectory* dir, const char* leaf = NULL, bool normalize = false); void Unset(); @@ -47,6 +47,7 @@ public: const char* Path() const; const char* Leaf() const; status_t GetParent(BPath* path) const; + bool IsAbsolute() const; bool operator==(const BPath& item) const; bool operator==(const char* path) const; diff --git a/src/kits/storage/Path.cpp b/src/kits/storage/Path.cpp index 7ba3171ab8..7c612992cd 100644 --- a/src/kits/storage/Path.cpp +++ b/src/kits/storage/Path.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009, Haiku Inc. + * Copyright 2002-2012, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -7,11 +7,13 @@ * Ingo Weinhold, bonefish@users.sf.net */ + /*! \file Path.cpp BPath implementation. */ + #include #include @@ -402,6 +404,16 @@ BPath::GetParent(BPath* path) const } +bool +BPath::IsAbsolute() const +{ + if (InitCheck() != B_OK) + return false; + + return fName[0] == '/'; +} + + /*! \brief Performs a simple (string-wise) comparison of paths. No normalization takes place! Uninitialized BPath objects are considered to be equal.