diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-16 22:20:54 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-05 23:38:41 +0200 |
| commit | 8a8c977c12fc65f1f50ea05099387e0fc8840e7d (patch) | |
| tree | 2d2c8663652939d643779d1ab1c18a12813fcbd2 /src/lib/cross_windows.cc | |
| parent | efe153ab23b54cdbf28c653f2ccb0f25ca6bd015 (diff) | |
Use dcp::File in DCP-o-matic (#2231).
Diffstat (limited to 'src/lib/cross_windows.cc')
| -rw-r--r-- | src/lib/cross_windows.cc | 64 |
1 files changed, 3 insertions, 61 deletions
diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc index f76380836..12fb5efa0 100644 --- a/src/lib/cross_windows.cc +++ b/src/lib/cross_windows.cc @@ -162,7 +162,7 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) return; } - auto o = fopen_boost (out, "w"); + dcp::File o(out, "w"); if (!o) { LOG_ERROR_NC (N_("ffprobe call failed (could not create output file)")); return; @@ -176,10 +176,10 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) if (!ReadFile(child_stderr_read, buffer, sizeof(buffer), &read, 0) || read == 0) { break; } - fwrite (buffer, read, 1, o); + o.write(buffer, read, 1); } - fclose (o); + o.close(); WaitForSingleObject (process_info.hProcess, INFINITE); CloseHandle (process_info.hProcess); @@ -232,64 +232,6 @@ disk_writer_path () #endif -/** Windows can't "by default" cope with paths longer than 260 characters, so if you pass such a path to - * any boost::filesystem method it will fail. There is a "fix" for this, which is to prepend - * the string \\?\ to the path. This will make it work, so long as: - * - the path is absolute. - * - the path only uses backslashes. - * - individual path components are "short enough" (probably less than 255 characters) - * - * See https://www.boost.org/doc/libs/1_57_0/libs/filesystem/doc/reference.html under - * "Warning: Long paths on Windows" for some details. - * - * Our fopen_boost uses this method to get this fix, but any other calls to boost::filesystem - * will not unless this method is explicitly called to pre-process the pathname. - */ -boost::filesystem::path -fix_long_path (boost::filesystem::path long_path) -{ - using namespace boost::filesystem; - - if (boost::algorithm::starts_with(long_path.string(), "\\\\")) { - /* This could mean it starts with \\ (i.e. a SMB path) or \\?\ (a long path) - * or a variety of other things... anyway, we'll leave it alone. - */ - return long_path; - } - - /* We have to make the path canonical but we can't call canonical() on the long path - * as it will fail. So we'll sort of do it ourselves (possibly badly). - */ - path fixed = "\\\\?\\"; - if (long_path.is_absolute()) { - fixed += long_path.make_preferred(); - } else { - fixed += boost::filesystem::current_path() / long_path.make_preferred(); - } - return fixed; -} - - -/* Apparently there is no way to create an ofstream using a UTF-8 - filename under Windows. We are hence reduced to using fopen - with this wrapper. -*/ -FILE * -fopen_boost (boost::filesystem::path p, string t) -{ - wstring w (t.begin(), t.end()); - /* c_str() on fixed here should give a UTF-16 string */ - return _wfopen (fix_long_path(p).c_str(), w.c_str()); -} - - -int -dcpomatic_fseek (FILE* stream, int64_t offset, int whence) -{ - return _fseeki64 (stream, offset, whence); -} - - void Waker::nudge () { |
