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);