Skip to content
Snippets Groups Projects
Commit 5e2d9e02 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

fileutils: improve Windows hard link file handling

Fix file access issues when reading hard links on Windows by:
- Adding explicit share mode (_SH_DENYNO) to allow reading files opened
  elsewhere
- Using binary mode to ensure consistent behavior with hard links

This resolves issues with reading hard linked files on Windows while
maintaining behavior on other platforms.

jami-client-qt#1899
Change-Id: I2adc0f29db46d5bf5b69762018e7a5e677ec3d04
parent d5ce21e3
No related branches found
No related tags found
No related merge requests found
......@@ -275,9 +275,18 @@ std::string
loadTextFile(const std::filesystem::path& path, const std::filesystem::path& default_dir)
{
std::string buffer;
std::ifstream file(getFullPath(default_dir, path));
auto fullPath = getFullPath(default_dir, path);
// Open with explicit share mode to allow reading even if file is opened elsewhere
#ifdef _WIN32
std::ifstream file(fullPath, std::ios::in | std::ios::binary, _SH_DENYNO);
#else
std::ifstream file(fullPath);
#endif
if (!file)
throw std::runtime_error("Unable to read file: " + path.string());
file.seekg(0, std::ios::end);
auto size = file.tellg();
if (size > std::numeric_limits<unsigned>::max())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment