Skip to content

Commit

Permalink
java_launcher: Fix non-portable ofstream usage
Browse files Browse the repository at this point in the history
wofstream cannot be constructed from wstring according to the standard https://en.cppreference.com/w/cpp/io/basic_ofstream/basic_ofstream.

Closes #24703.

PiperOrigin-RevId: 707172911
Change-Id: I973f9560c5b20748e4635cd757f53fff9c8ef0c5
  • Loading branch information
BoleynSu authored and copybara-github committed Dec 17, 2024
1 parent e8925c3 commit 5b35276
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tools/launcher/java_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ wstring JavaBinaryLauncher::CreateClasspathJar(const wstring& classpath) {
wstring jar_manifest_file_path =
binary_base_path + rand_id + L".jar_manifest";
blaze_util::AddUncPrefixMaybe(&jar_manifest_file_path);
#if (__cplusplus >= 201703L)
wofstream jar_manifest_file(std::filesystem::path(jar_manifest_file_path));
#else
wofstream jar_manifest_file(jar_manifest_file_path);
#endif
jar_manifest_file << L"Manifest-Version: 1.0\n";
// No line in the MANIFEST.MF file may be longer than 72 bytes.
// A space prefix indicates the line is still the content of the last
Expand Down

0 comments on commit 5b35276

Please sign in to comment.