Added BPath::IsAbsolute() method.
This commit is contained in:
parent
43d413e3f7
commit
2de44bbde7
@ -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;
|
||||
|
@ -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 <Path.h>
|
||||
|
||||
#include <new>
|
||||
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user