Skip to content
Open
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
10 changes: 0 additions & 10 deletions src/lib/OpenEXR/ImfMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
#include <ImfTileDescription.h>
#include <ImfXdr.h>

#include <codecvt>
#include <locale>

OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER

using IMATH_NAMESPACE::Box2i;
Expand Down Expand Up @@ -1996,13 +1993,6 @@ getChunkOffsetTableSize (const Header& header)
return getTiledChunkOffsetTableSize (header);
}

std::wstring
WidenFilename (const char* filename)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
return converter.from_bytes (filename);
}

const char*
getLibraryVersion ()
{
Expand Down
8 changes: 0 additions & 8 deletions src/lib/OpenEXR/ImfMisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,6 @@ bool usesLongNames (const Header& header);
IMF_EXPORT
int getChunkOffsetTableSize (const Header& header);

//
// Convert a filename to a wide string. This is useful for working with
// filenames on Windows.
//

IMF_EXPORT
std::wstring WidenFilename (const char* filename);

//
// Return the string that describes the major.minor.patch release version
//
Expand Down
16 changes: 13 additions & 3 deletions src/test/OpenEXRTest/TestUtilFStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#ifndef INCLUDE_TestUtilFStream_h_
# define INCLUDE_TestUtilFStream_h_ 1

# include <ImfMisc.h>

# include <fstream>
# include <string>

Expand All @@ -28,6 +26,18 @@
namespace testutil
{
# ifdef _WIN32
// Convert UTF-8 filename to wide string for Windows APIs. Test-only; uses
// MultiByteToWideChar to avoid deprecated std::codecvt_utf8.
inline std::wstring
WidenFilename (const char* filename)
{
if (!filename || !*filename) return std::wstring ();
int len = MultiByteToWideChar (CP_UTF8, 0, filename, -1, nullptr, 0);
if (len <= 0) return std::wstring ();
std::wstring result (static_cast<size_t> (len) - 1, L'\0');
MultiByteToWideChar (CP_UTF8, 0, filename, -1, &result[0], len);
return result;
}
// This is a big work around mechanism for compiling using mingw / gcc under windows
// until mingw 9 where they add the wide filename version of open
# if ( \
Expand Down Expand Up @@ -104,7 +114,7 @@ OpenStreamWithUTF8Name (
StreamType& is, const char* filename, std::ios_base::openmode mode)
{
# ifdef _WIN32
std::wstring wfn = OPENEXR_IMF_INTERNAL_NAMESPACE::WidenFilename (filename);
std::wstring wfn = WidenFilename (filename);
# ifdef USE_WIDEN_FILEBUF
Copy link
Copy Markdown

@kmilos kmilos Mar 20, 2026

Choose a reason for hiding this comment

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

Note that because this is an API change, it needs to wait for the next major release.

One more reason to drop this legacy USE_WIDEN_FILEBUF code path (here and L36)?

using CharT = typename StreamType::char_type;
using TraitsT = typename StreamType::traits_type;
Expand Down
7 changes: 3 additions & 4 deletions src/test/OpenEXRTest/testExistingStreams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <ImfArray.h>
#include <ImfCompressor.h>
#include <ImfInputPart.h>
#include <ImfMisc.h>
#include <ImfMultiPartInputFile.h>
#include <ImfMultiPartOutputFile.h>
#include <ImfOutputPart.h>
Expand Down Expand Up @@ -127,7 +126,7 @@ MMIFStream::MMIFStream (const char fileName[])
, _length (0)
{
#ifdef _WIN32
const std::wstring fileNameWide = WidenFilename (fileName);
const std::wstring fileNameWide = testutil::WidenFilename (fileName);
try
{
_f = CreateFileW (
Expand Down Expand Up @@ -1093,7 +1092,7 @@ testExistingStreamsUTF8 (const std::string& tempDir)
{
cout << "writing";
#ifdef _WIN32
_wremove (WidenFilename (outfn.c_str ()).c_str ());
_wremove (testutil::WidenFilename (outfn.c_str ()).c_str ());
#else
remove (outfn.c_str ());
#endif
Expand Down Expand Up @@ -1144,7 +1143,7 @@ testExistingStreamsUTF8 (const std::string& tempDir)
cout << endl;

#ifdef _WIN32
_wremove (WidenFilename (outfn.c_str ()).c_str ());
_wremove (testutil::WidenFilename (outfn.c_str ()).c_str ());
#else
remove (outfn.c_str ());
#endif
Expand Down
Loading