Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cppwinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "component_writers.h"
#include "file_writers.h"
#include "type_writers.h"
#include <winternl.h>

namespace cppwinrt
{
Expand Down Expand Up @@ -374,5 +375,7 @@ Where <spec> is one or more of:

int main(int const argc, char** argv)
{
// Dynamically enable long path support
((unsigned char*)(NtCurrentTeb()->ProcessEnvironmentBlock))[3] |= 0x80;
Copy link
Member

Choose a reason for hiding this comment

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

We should not be calling undocumented APIs from cppwinrt.exe.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there an alternative or do we pull it out?

Copy link
Member Author

Choose a reason for hiding this comment

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

An alternative is to create an app manifest; I had tried doing that, the manifest was getting embedded, but long path were still not working. We could pull out this one line from the code and leave the error reporting, and I can try to rework the manifest. LMK what you'd like to do.

Copy link
Member Author

Choose a reason for hiding this comment

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

PR to use the manifest here: #882

return cppwinrt::run(argc, argv);
}
15 changes: 12 additions & 3 deletions cppwinrt/text_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,18 @@ namespace cppwinrt
{
if (!file_equal(filename))
{
std::ofstream file{ filename, std::ios::out | std::ios::binary };
file.write(m_first.data(), m_first.size());
file.write(m_second.data(), m_second.size());
std::ofstream file;
file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
try
{
file.open(filename, std::ios::out | std::ios::binary);
file.write(m_first.data(), m_first.size());
file.write(m_second.data(), m_second.size());
}
catch (std::ofstream::failure const& e)
{
throw std::filesystem::filesystem_error(e.what(), filename, std::io_errc::stream);
}
}
m_first.clear();
m_second.clear();
Expand Down