2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
#include <string>
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DiscIO/FileBlob.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
namespace DiscIO
|
|
|
|
{
|
|
|
|
|
2011-03-11 10:21:46 +00:00
|
|
|
PlainFileReader::PlainFileReader(std::FILE* file)
|
|
|
|
: m_file(file)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-03-11 10:21:46 +00:00
|
|
|
m_size = m_file.GetSize();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
PlainFileReader* PlainFileReader::Create(const std::string& filename)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-03-11 10:21:46 +00:00
|
|
|
File::IOFile f(filename, "rb");
|
2011-01-27 05:01:00 +00:00
|
|
|
if (f)
|
2011-03-11 10:21:46 +00:00
|
|
|
return new PlainFileReader(f.ReleaseHandle());
|
2008-12-08 05:30:24 +00:00
|
|
|
else
|
2014-03-09 20:14:26 +00:00
|
|
|
return nullptr;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
|
|
|
|
{
|
2011-03-11 10:21:46 +00:00
|
|
|
m_file.Seek(offset, SEEK_SET);
|
|
|
|
return m_file.ReadBytes(out_ptr, nbytes);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|