summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-09-03 17:55:11 +0200
committerCarl Hetherington <cth@carlh.net>2024-09-03 17:55:19 +0200
commit4049ec5e8bdddbc48689521a26bf47236c2b490d (patch)
tree6532546b5a1edcd77e8824d8cd854eac13e38c44
parent5db3eda9c6f0d6b027263c519000997677253504 (diff)
Fix a few places where we should use dcp::File::open_error()
to get a more accurate error number on Windows.
-rw-r--r--src/lib/file_group.cc2
-rw-r--r--src/lib/film.cc2
-rw-r--r--src/lib/string_text_file.cc2
-rw-r--r--src/lib/util.cc8
-rw-r--r--src/lib/writer.cc2
-rw-r--r--src/wx/config_dialog.cc12
6 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc
index 469d07702..27137196e 100644
--- a/src/lib/file_group.cc
+++ b/src/lib/file_group.cc
@@ -86,7 +86,7 @@ FileGroup::ensure_open_path (size_t p) const
auto file = dcp::File(_paths[_current_path], "rb");
if (!file) {
- throw OpenFileError(_paths[_current_path], errno, OpenFileError::READ);
+ throw OpenFileError(_paths[_current_path], file.open_error(), OpenFileError::READ);
}
_current_path = p;
diff --git a/src/lib/film.cc b/src/lib/film.cc
index d9ab6e2a3..674add78f 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -2092,7 +2092,7 @@ InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path pat
, _file(path, read ? "rb" : (dcp::filesystem::exists(path) ? "r+b" : "wb"))
{
if (!_file) {
- throw OpenFileError(path, errno, read ? OpenFileError::READ : (dcp::filesystem::exists(path) ? OpenFileError::READ_WRITE : OpenFileError::WRITE));
+ throw OpenFileError(path, _file.open_error(), read ? OpenFileError::READ : (dcp::filesystem::exists(path) ? OpenFileError::READ_WRITE : OpenFileError::WRITE));
}
}
diff --git a/src/lib/string_text_file.cc b/src/lib/string_text_file.cc
index 9b43b35a6..f5d5e0d2a 100644
--- a/src/lib/string_text_file.cc
+++ b/src/lib/string_text_file.cc
@@ -57,7 +57,7 @@ StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content)
if (ext == ".stl") {
dcp::File f(content->path(0), "rb");
if (!f) {
- throw OpenFileError (f.path(), errno, OpenFileError::READ);
+ throw OpenFileError(f.path(), f.open_error(), OpenFileError::READ);
}
try {
reader.reset(new sub::STLBinaryReader(f.get()));
diff --git a/src/lib/util.cc b/src/lib/util.cc
index f637534a9..8b767cd15 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -559,7 +559,7 @@ digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
while (i < int64_t (files.size()) && to_do > 0) {
dcp::File f(files[i], "rb");
if (!f) {
- throw OpenFileError (files[i].string(), errno, OpenFileError::READ);
+ throw OpenFileError(files[i].string(), f.open_error(), OpenFileError::READ);
}
auto this_time = min(to_do, dcp::filesystem::file_size(files[i]));
@@ -578,7 +578,7 @@ digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
while (i >= 0 && to_do > 0) {
dcp::File f(files[i], "rb");
if (!f) {
- throw OpenFileError (files[i].string(), errno, OpenFileError::READ);
+ throw OpenFileError(files[i].string(), f.open_error(), OpenFileError::READ);
}
auto this_time = min(to_do, dcp::filesystem::file_size(files[i]));
@@ -956,11 +956,11 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::fun
{
dcp::File f(from, "rb");
if (!f) {
- throw OpenFileError (from, errno, OpenFileError::READ);
+ throw OpenFileError(from, f.open_error(), OpenFileError::READ);
}
dcp::File t(to, "wb");
if (!t) {
- throw OpenFileError (to, errno, OpenFileError::WRITE);
+ throw OpenFileError(to, t.open_error(), OpenFileError::WRITE);
}
/* on the order of a second's worth of copying */
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 7b9defd73..37b8e4ccb 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -728,7 +728,7 @@ Writer::write_cover_sheet (boost::filesystem::path output_dcp)
auto const cover = film()->file("COVER_SHEET.txt");
dcp::File file(cover, "w");
if (!file) {
- throw OpenFileError (cover, errno, OpenFileError::WRITE);
+ throw OpenFileError(cover, file.open_error(), OpenFileError::WRITE);
}
auto text = Config::instance()->cover_sheet ();
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index 12e914742..da39c443a 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -473,7 +473,7 @@ CertificateChainEditor::export_certificate ()
}
dcp::File f(path, "w");
if (!f) {
- throw OpenFileError(path, errno, OpenFileError::WRITE);
+ throw OpenFileError(path, f.open_error(), OpenFileError::WRITE);
}
string const s = j->certificate(true);
@@ -498,7 +498,7 @@ CertificateChainEditor::export_chain ()
}
dcp::File f(path, "w");
if (!f) {
- throw OpenFileError(path, errno, OpenFileError::WRITE);
+ throw OpenFileError(path, f.open_error(), OpenFileError::WRITE);
}
auto const s = _get()->chain();
@@ -619,7 +619,7 @@ CertificateChainEditor::export_private_key ()
}
dcp::File f(path, "w");
if (!f) {
- throw OpenFileError (path, errno, OpenFileError::WRITE);
+ throw OpenFileError(path, f.open_error(), OpenFileError::WRITE);
}
auto const s = _get()->key().get ();
@@ -737,7 +737,7 @@ KeysPage::export_decryption_chain_and_key ()
boost::filesystem::path path(wx_to_std(d->GetPath()));
dcp::File f(path, "w");
if (!f) {
- throw OpenFileError(path, errno, OpenFileError::WRITE);
+ throw OpenFileError(path, f.open_error(), OpenFileError::WRITE);
}
auto const chain = Config::instance()->decryption_chain()->chain();
@@ -771,7 +771,7 @@ KeysPage::import_decryption_chain_and_key ()
dcp::File f(wx_to_std(d->GetPath()), "r");
if (!f) {
- throw OpenFileError(f.path(), errno, OpenFileError::WRITE);
+ throw OpenFileError(f.path(), f.open_error(), OpenFileError::WRITE);
}
string current;
@@ -836,7 +836,7 @@ KeysPage::export_decryption_certificate ()
}
dcp::File f(path, "w");
if (!f) {
- throw OpenFileError(path, errno, OpenFileError::WRITE);
+ throw OpenFileError(path, f.open_error(), OpenFileError::WRITE);
}
auto const s = Config::instance()->decryption_chain()->leaf().certificate (true);