From b20073726af5c47239330deb359d63c75df2da58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 12 Nov 2012 23:49:38 +0100 Subject: [PATCH] Added BEntry::Name() method. * GetName() is a bad API, and should be deprecated. --- headers/os/storage/Entry.h | 4 +++- src/kits/storage/Entry.cpp | 29 +++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/headers/os/storage/Entry.h b/headers/os/storage/Entry.h index f0c628e49e..60a5a56179 100644 --- a/headers/os/storage/Entry.h +++ b/headers/os/storage/Entry.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2012, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ENTRY_H @@ -50,6 +50,8 @@ public: status_t InitCheck() const; bool Exists() const; + const char* Name() const; + virtual status_t GetStat(struct stat* stat) const; status_t SetTo(const BDirectory* dir, const char* path, diff --git a/src/kits/storage/Entry.cpp b/src/kits/storage/Entry.cpp index 7ff8715695..d04038fd38 100644 --- a/src/kits/storage/Entry.cpp +++ b/src/kits/storage/Entry.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009, Haiku Inc. + * Copyright 2002-2012, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -191,6 +191,16 @@ BEntry::Exists() const } +const char* +BEntry::Name() const +{ + if (fCStatus != B_OK) + return NULL; + + return fName; +} + + status_t BEntry::SetTo(const BDirectory* dir, const char* path, bool traverse) { @@ -360,18 +370,13 @@ BEntry::GetParent(BDirectory* dir) const status_t BEntry::GetName(char* buffer) const { - status_t result = B_ERROR; + if (fCStatus != B_OK) + return B_NO_INIT; + if (buffer == NULL) + return B_BAD_VALUE; - if (fCStatus != B_OK) { - result = B_NO_INIT; - } else if (buffer == NULL) { - result = B_BAD_VALUE; - } else { - strcpy(buffer, fName); - result = B_OK; - } - - return result; + strcpy(buffer, fName); + return B_OK; }