2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
6 #include "DataSource.h"
13 // #pragma mark - DataSource
16 DataSource::DataSource()
21 DataSource::~DataSource()
27 DataSource::GetName(BString
& name
)
33 // #pragma mark - FileDataSource
38 FileDataSource::CreateDataIO(BDataIO
** _io
)
40 BFile
* file
= new(std::nothrow
) BFile
;
44 status_t error
= OpenFile(*file
);
55 // #pragma mark - PathDataSource
59 PathDataSource::Init(const char* path
)
61 return fPath
.SetTo(path
);
66 PathDataSource::GetName(BString
& name
)
68 if (fPath
.Path() == NULL
)
77 PathDataSource::OpenFile(BFile
& file
)
79 return file
.SetTo(fPath
.Path(), B_READ_ONLY
);
83 // #pragma mark - EntryRefDataSource
87 EntryRefDataSource::Init(const entry_ref
* ref
)
89 if (ref
->name
== NULL
)
93 if (fRef
.name
== NULL
)
101 EntryRefDataSource::GetName(BString
& name
)
104 status_t error
= entry
.SetTo(&fRef
);
109 error
= entry
.GetPath(&path
);
119 EntryRefDataSource::OpenFile(BFile
& file
)
121 return file
.SetTo(&fRef
, B_READ_ONLY
);