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
7 changes: 6 additions & 1 deletion src/modules/FileLocksmith/FileLocksmithLib/IPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ namespace ipc

try
{
m_stream = std::ofstream(path);
m_stream = std::ofstream(path, std::ios::binary);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added an explicit is_open() check in ipc::Writer::start() after opening the stream in binary mode, so open failures now return E_FAIL instead of incorrectly returning S_OK.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Found the other last-run.log write path in src/modules/FileLocksmith/FileLocksmithLibInterop/NativeMethods.cpp (NativeMethods::StartAsElevated) and switched that std::ofstream open to std::ios::binary as well.

if (!m_stream.is_open())
{
return E_FAIL;
}

return S_OK;
}
catch (...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace winrt::PowerToys::FileLocksmithLib::Interop::implementation

com_array<hstring> NativeMethods::ReadPathsFromFile()
{
std::ifstream stream(paths_file());
std::ifstream stream(paths_file(), std::ios::binary);

std::vector<std::wstring> result_cpp;
std::wstring line;
Expand Down Expand Up @@ -98,7 +98,7 @@ namespace winrt::PowerToys::FileLocksmithLib::Interop::implementation

bool NativeMethods::StartAsElevated(array_view<hstring const> paths)
{
std::ofstream stream(paths_file());
std::ofstream stream(paths_file(), std::ios::binary);
const WCHAR newline = L'\n';

for (uint32_t i = 0; i < paths.size(); i++)
Expand Down
Loading