mirror of
https://github.com/QuasarApp/LIEF.git
synced 2025-05-12 03:19:34 +00:00
Merge pull request #513 from aguinet/feature/fatmacho_take
Fat MachO: API to "take" a binary from the fat MachO object
This commit is contained in:
commit
eccc0bbc61
@ -17,6 +17,7 @@
|
||||
#define LIEF_MACHO_FAT_BINARY_H_
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "LIEF/types.hpp"
|
||||
#include "LIEF/visibility.h"
|
||||
@ -62,6 +63,11 @@ class LIEF_API FatBinary {
|
||||
Binary& operator[](size_t index);
|
||||
const Binary& operator[](size_t index) const;
|
||||
|
||||
//! Extract a @link MachO::Binary@ object. Gives ownership to the caller, and
|
||||
// remove it from this @link FatBinary object. Warning: this invalidates any
|
||||
// previously hold iterator!
|
||||
std::unique_ptr<Binary> take(size_t index);
|
||||
|
||||
//! Reconstruct the Fat binary object and write it in `filename`
|
||||
//! @param filename Path to write the reconstructed binary
|
||||
void write(const std::string& filename);
|
||||
|
@ -91,6 +91,16 @@ const Binary& FatBinary::operator[](size_t index) const {
|
||||
return this->at(index);
|
||||
}
|
||||
|
||||
std::unique_ptr<Binary> FatBinary::take(size_t index) {
|
||||
if (index >= binaries_.size()) {
|
||||
return {};
|
||||
}
|
||||
auto it = binaries_.begin();
|
||||
std::advance(it, index);
|
||||
std::unique_ptr<Binary> ret(*it);
|
||||
binaries_.erase(it);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FatBinary::write(const std::string& filename) {
|
||||
Builder::write(this, filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user