Single-File: MemoryMap the bundle file (dotnet/core-setup#6576)
authorSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Mon, 19 Aug 2019 18:52:03 +0000 (11:52 -0700)
committerGitHub <noreply@github.com>
Mon, 19 Aug 2019 18:52:03 +0000 (11:52 -0700)
commit40be2e63d7966f3551392db4aa0e419bc196fc60
tree81914313851d82e26c976f4530c1ea6527350ca2
parent183ef571c974761d6d00d8634fefe61fee786b90
Single-File: MemoryMap the bundle file (dotnet/core-setup#6576)

* Single-File: MemoryMap the bundle file

This changes makes a few changes in preparation for
loading IL files from the single-file bundle.

**Memory Mapping**

At startup, the entire bundle-file is memory mapped.
The individual embedded files are then extracted out to actual files on disk on startup.
However, this change will facilitate later checkins to:
* Loading files directly from bundle (ex: IL files using PELoader, config files using memory-streams, etc ).
* Extracting out files to disk lazily
Further details are available in [this document](https://github.com/dotnet/designs/blob/master/accepted/single-file/design.md#the-host)

**Refactoring**

* Static bundle_runner: The bundle_runner is made a static class that holds a global pointer
  to the memory-mapped application bundle, and meta-data about the contents.
  This facilitates the implementation of call-backs for accessing content directly from the bundle,
  as explained in [this document](https://github.com/dotnet/designs/blob/master/accepted/single-file/direct.md)

* A few new classes are created by factoring out functionality from bundle_runner
   * Extractor: Functionality for extracting contents of a bundle to files on disk.
   * Reader: This is a helper class that implements sequentional reading on memory-mapped bundle file.
   * dir-Util: Extraction directory handling utilities that assist in processing the bundle.

* Naming: bundle::bundle_runner is renamed as bundle::runner to remove the redundancy.
  Similarly, the newly refactored classes are named bundle::extractor and bundle::reader.

Commit migrated from https://github.com/dotnet/core-setup/commit/9bb119b2a4b82d54e73669928a3b831cc07a1291
21 files changed:
src/installer/corehost/cli/apphost/CMakeLists.txt
src/installer/corehost/cli/apphost/bundle/bundle_runner.cpp [deleted file]
src/installer/corehost/cli/apphost/bundle/bundle_runner.h [deleted file]
src/installer/corehost/cli/apphost/bundle/dir_utils.cpp [new file with mode: 0644]
src/installer/corehost/cli/apphost/bundle/dir_utils.h [new file with mode: 0644]
src/installer/corehost/cli/apphost/bundle/extractor.cpp [new file with mode: 0644]
src/installer/corehost/cli/apphost/bundle/extractor.h [new file with mode: 0644]
src/installer/corehost/cli/apphost/bundle/file_entry.cpp
src/installer/corehost/cli/apphost/bundle/file_entry.h
src/installer/corehost/cli/apphost/bundle/header.cpp
src/installer/corehost/cli/apphost/bundle/header.h
src/installer/corehost/cli/apphost/bundle/manifest.cpp
src/installer/corehost/cli/apphost/bundle/manifest.h
src/installer/corehost/cli/apphost/bundle/reader.cpp [new file with mode: 0644]
src/installer/corehost/cli/apphost/bundle/reader.h [new file with mode: 0644]
src/installer/corehost/cli/apphost/bundle/runner.cpp [new file with mode: 0644]
src/installer/corehost/cli/apphost/bundle/runner.h [new file with mode: 0644]
src/installer/corehost/common/pal.h
src/installer/corehost/common/pal.unix.cpp
src/installer/corehost/common/pal.windows.cpp
src/installer/corehost/corehost.cpp