Skip to content

pe_writer and allow reader::database to accept a buffer instead of a file path#326

Merged
DefaultRyan merged 4 commits into
masterfrom
defaultryan/pe_writer
Apr 18, 2019
Merged

pe_writer and allow reader::database to accept a buffer instead of a file path#326
DefaultRyan merged 4 commits into
masterfrom
defaultryan/pe_writer

Conversation

@DefaultRyan

Copy link
Copy Markdown
Member

This change introduces xlang::meta::writer::pe_writer, which can write out a compliant PE format executable file (aka winmd).

To improve testability, I've also modified xlang::meta::reader::database to accept a std::vector<uint8_t> buffer instead of a file path. This way, we can consume and decode the writer's output without needing to touch the file system.

@DefaultRyan DefaultRyan requested a review from kennykerr as a code owner April 17, 2019 23:35
}

explicit database(std::string_view const& path, cache const* cache = nullptr) : file_view{ path }, m_path{ path }, m_cache{ cache }
explicit database(std::vector<uint8_t>&& buffer, cache const* cache = nullptr) : m_buffer{ std::move(buffer) }, m_view{ m_buffer.data(), m_buffer.data() + m_buffer.size() }, m_cache{ cache }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff isn't rendering well. All that really happened here is:

  • Moved the code in the current constructor into a private initialize method
  • Added a constructor that takes std::vector<uint8_t>

@Scottj1s Scottj1s left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see generalizing a steam concept to pass into the writer, defaulting to file. But this is fine for now.

@DefaultRyan DefaultRyan merged commit 095df7f into master Apr 18, 2019
@DefaultRyan DefaultRyan deleted the defaultryan/pe_writer branch April 18, 2019 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants