⛏️ index : haiku.git

author Axel Dörfler <axeld@pinc-software.de> 2012-11-04 17:21:12.0 +01:00:00
committer Alexander von Gluck IV <kallisti5@unixzen.com> 2012-11-07 7:48:38.0 -06:00:00
commit
2de44bbde71ea183741f0bd1efb1bdf0b5886592 [patch]
tree
03843041fb2509087048ae560ac8c2b2401a7ee2
parent
43d413e3f779c5c6b3cf78cb1c5306e65f8af4ba
download
2de44bbde71ea183741f0bd1efb1bdf0b5886592.tar.gz

Added BPath::IsAbsolute() method.



Diff

 headers/os/storage/Path.h |  7 +++++--
 src/kits/storage/Path.cpp | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/headers/os/storage/Path.h b/headers/os/storage/Path.h
index 13438a4..d12723a 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 @@
							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 @@
			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 @@
			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 7ba3171..7c61299 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,10 +7,12 @@
 *		Ingo Weinhold, bonefish@users.sf.net
 */


/*!
	\file Path.cpp
	BPath implementation.
*/


#include <Path.h>

@@ -399,6 +401,16 @@
	parentPath[length] = '\0';

	return path->SetTo(parentPath);
}


bool
BPath::IsAbsolute() const
{
	if (InitCheck() != B_OK)
		return false;

	return fName[0] == '/';
}