diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-08-07 11:10:07 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-08-07 11:22:30 +0200 |
commit | 793b409eeae2b42be7fed58251afa87b5733ca4d (patch) | |
tree | e931d576f8bfc7b766c69bf3202dad5de2adf0a7 /src/tools | |
parent | 242a43449dd44a22857f6ce95f7cc6a7e134d298 (diff) |
Windows, sh_bin. launcher: fix manifest path
Fix the path we set in the exe launcher for the
RUNFILES_MANIFEST_FILE path. It now uses forward
slashes because it's to be consumed by the shell
script.
This is a follow-up to commit 837e1b3d4859140d29aaa6bbab8fbb008e6d701e
Change-Id: Id8331cdcf58adb31ed2b60ebbc57022a0bf32438
PiperOrigin-RevId: 164436539
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/launcher/launcher.cc | 10 | ||||
-rw-r--r-- | src/tools/launcher/util/launcher_util.cc | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/tools/launcher/launcher.cc b/src/tools/launcher/launcher.cc index d3a023eb8b..9aaa8a5924 100644 --- a/src/tools/launcher/launcher.cc +++ b/src/tools/launcher/launcher.cc @@ -13,6 +13,7 @@ // limitations under the License. #include <windows.h> +#include <algorithm> #include <fstream> #include <iostream> #include <sstream> @@ -47,8 +48,12 @@ string BinaryLauncherBase::FindManifestFile(const char* argv0) { // Get the name of the binary string binary = GetBinaryPathWithoutExtension(argv0); + // The path will be set as the RUNFILES_MANIFEST_FILE envvar and used by the + // shell script, so let's convert backslashes to forward slashes. + std::replace(binary.begin(), binary.end(), '\\', '/'); + // Try to find <path to binary>.runfiles/MANIFEST - string manifest_file = binary + ".runfiles\\MANIFEST"; + string manifest_file = binary + ".runfiles/MANIFEST"; if (DoesFilePathExist(manifest_file.c_str())) { return manifest_file; } @@ -64,6 +69,9 @@ string BinaryLauncherBase::FindManifestFile(const char* argv0) { void BinaryLauncherBase::ParseManifestFile(ManifestFileMap* manifest_file_map, const string& manifest_path) { + // TODO(laszlocsomor): prefix manifest_path with the longpath prefix. + // std::ifstream supports long paths, but only if they are in the correct + // format, e.g. "\\\\?\\c:\\imagine\\some\\very\\long\\path.txt". ifstream manifest_file(manifest_path.c_str()); if (!manifest_file) { diff --git a/src/tools/launcher/util/launcher_util.cc b/src/tools/launcher/util/launcher_util.cc index 610516bcc3..247c7050c5 100644 --- a/src/tools/launcher/util/launcher_util.cc +++ b/src/tools/launcher/util/launcher_util.cc @@ -68,7 +68,9 @@ void PrintError(const char* format, ...) { } bool DoesFilePathExist(const char* path) { - DWORD dwAttrib = GetFileAttributes(path); + // TODO(laszlocsomor): convert `path` to (const wchar_t*), add longpath-prefix + // and use GetFileAttributesW. + DWORD dwAttrib = GetFileAttributesA(path); return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); |