2018-01-01 21:04:13 +00:00
|
|
|
//
|
|
|
|
// CSROMFetcher.m
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 01/01/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-01-01 21:04:13 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#include "CSROMFetcher.hpp"
|
|
|
|
|
|
|
|
#import "NSBundle+DataResource.h"
|
|
|
|
#import "NSData+StdVector.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2018-01-25 23:28:19 +00:00
|
|
|
ROMMachine::ROMFetcher CSROMFetcher() {
|
|
|
|
return [] (const std::string &machine, const std::vector<std::string> &names) -> std::vector<std::unique_ptr<std::vector<std::uint8_t>>> {
|
2018-01-01 21:04:13 +00:00
|
|
|
NSString *subDirectory = [@"ROMImages/" stringByAppendingString:[NSString stringWithUTF8String:machine.c_str()]];
|
|
|
|
std::vector<std::unique_ptr<std::vector<std::uint8_t>>> results;
|
2018-05-01 02:23:57 +00:00
|
|
|
for(const auto &name: names) {
|
2018-01-01 21:04:13 +00:00
|
|
|
NSData *fileData = [[NSBundle mainBundle] dataForResource:[NSString stringWithUTF8String:name.c_str()] withExtension:nil subdirectory:subDirectory];
|
|
|
|
|
|
|
|
if(!fileData)
|
|
|
|
results.emplace_back(nullptr);
|
|
|
|
else {
|
|
|
|
std::unique_ptr<std::vector<std::uint8_t>> data(new std::vector<std::uint8_t>);
|
|
|
|
*data = fileData.stdVector8;
|
|
|
|
results.emplace_back(std::move(data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
2018-01-25 23:28:19 +00:00
|
|
|
};
|
2018-01-01 21:04:13 +00:00
|
|
|
}
|