From 602a9fe54dfd3679b083ae4bff48701e4267b330 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 25 Apr 2009 20:49:34 +0000 Subject: [PATCH] Added optional DataSource::GetName() to get a name for the data source. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30410 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debuganalyzer/util/DataSource.cpp | 38 ++++++++++++++++++++++ src/apps/debuganalyzer/util/DataSource.h | 9 +++++ 2 files changed, 47 insertions(+) diff --git a/src/apps/debuganalyzer/util/DataSource.cpp b/src/apps/debuganalyzer/util/DataSource.cpp index a7f175d8c1..0ed98ae33b 100644 --- a/src/apps/debuganalyzer/util/DataSource.cpp +++ b/src/apps/debuganalyzer/util/DataSource.cpp @@ -7,6 +7,8 @@ #include +#include + // #pragma mark - DataSource @@ -21,6 +23,13 @@ DataSource::~DataSource() } +status_t +DataSource::GetName(BString& name) +{ + return B_UNSUPPORTED; +} + + // #pragma mark - FileDataSource @@ -53,6 +62,17 @@ PathDataSource::Init(const char* path) } +status_t +PathDataSource::GetName(BString& name) +{ + if (fPath.Path() == NULL) + return B_NO_INIT; + + name = fPath.Path(); + return B_OK; +} + + status_t PathDataSource::OpenFile(BFile& file) { @@ -77,6 +97,24 @@ EntryRefDataSource::Init(const entry_ref* ref) } +status_t +EntryRefDataSource::GetName(BString& name) +{ + BEntry entry; + status_t error = entry.SetTo(&fRef); + if (error != B_OK) + return error; + + BPath path; + error = entry.GetPath(&path); + if (error != B_OK) + return error; + + name = path.Path(); + return B_OK; +} + + status_t EntryRefDataSource::OpenFile(BFile& file) { diff --git a/src/apps/debuganalyzer/util/DataSource.h b/src/apps/debuganalyzer/util/DataSource.h index a5fa2c566a..880906eacd 100644 --- a/src/apps/debuganalyzer/util/DataSource.h +++ b/src/apps/debuganalyzer/util/DataSource.h @@ -10,12 +10,17 @@ #include +struct BString; + + class DataSource { public: DataSource(); virtual ~DataSource(); virtual status_t CreateDataIO(BDataIO** _io) = 0; + + virtual status_t GetName(BString& name); }; @@ -32,6 +37,8 @@ class PathDataSource : public FileDataSource { public: status_t Init(const char* path); + virtual status_t GetName(BString& name); + protected: virtual status_t OpenFile(BFile& file); @@ -44,6 +51,8 @@ class EntryRefDataSource : public FileDataSource { public: status_t Init(const entry_ref* ref); + virtual status_t GetName(BString& name); + protected: virtual status_t OpenFile(BFile& file);