Exemple #1
0
IStreamPtr BsaArchive::open(const Entry &entry)
{
    std::unique_ptr<std::istream> stream(new std::ifstream(mFilename.c_str(), std::ios::binary));
    if(!stream->seekg(entry.mStart))
        return IStreamPtr(nullptr);
    return IStreamPtr(new ConstrainedFileStream(std::move(stream), entry.mStart, entry.mEnd));
}
Exemple #2
0
IStreamPtr BsaArchive::open(const char *name)
{
    auto iter = std::lower_bound(mLookupName.begin(), mLookupName.end(), name);
    if(iter == mLookupName.end() || *iter != name)
        return IStreamPtr(nullptr);
    return open(mEntries[std::distance(mLookupName.begin(), iter)]);
}
 ///returnes empty pointer, but saves id for future usage
 virtual IStreamPtr createStream(const std::string& whereFrom){
     if(mRequests.size() < mMaxRequests)
         mRequests.push_back(whereFrom);
     return IStreamPtr();
 }
 IStreamPtr openConstrainedFileStream(const char *filename,
                                                    size_t start, size_t length)
 {
     return IStreamPtr(new ConstrainedFileStream(filename, start, length));
 }
 IStreamPtr openConstrainedFileStream(const char *filename,
                                                    size_t start, size_t length)
 {
     auto buf = std::unique_ptr<std::streambuf>(new ConstrainedFileStreamBuf(filename, start, length));
     return IStreamPtr(new ConstrainedFileStream(std::move(buf)));
 }