mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Add pluggable image readers, plus some documentation.
This commit is contained in:
31
lib/imagereader/imagereader.cc
Normal file
31
lib/imagereader/imagereader.cc
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "globals.h"
|
||||
#include "image.h"
|
||||
#include "flags.h"
|
||||
#include "dataspec.h"
|
||||
#include "sector.h"
|
||||
#include "sectorset.h"
|
||||
#include "imagereader/imagereader.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
static bool ends_with(const std::string& value, const std::string& ending)
|
||||
{
|
||||
if (ending.size() > value.size())
|
||||
return false;
|
||||
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
|
||||
}
|
||||
|
||||
std::unique_ptr<ImageReader> ImageReader::create(const ImageSpec& spec)
|
||||
{
|
||||
const auto& filename = spec.filename;
|
||||
|
||||
if (ends_with(filename, ".img") || ends_with(filename, ".adf"))
|
||||
return createImgImageReader(spec);
|
||||
|
||||
Error() << "unrecognised image filename extension";
|
||||
return std::unique_ptr<ImageReader>();
|
||||
}
|
||||
|
||||
ImageReader::ImageReader(const ImageSpec& spec):
|
||||
spec(spec)
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user