open will return true w/ error if non-fatal error reading but fd still valid

This commit is contained in:
Kelvin Sherlock 2017-07-26 10:05:27 -04:00
parent e2f1cb0b4b
commit d7660c16cc
1 changed files with 12 additions and 6 deletions

View File

@ -441,7 +441,8 @@ bool finder_info::open(const std::string &path, open_mode mode, std::error_code
if (ec) {
afp_init(&_afp);
return false;
if (mode == read_only) return false;
return true; // there was an error but the file is still open.
}
// warn if incorrect size or data.
@ -449,8 +450,8 @@ bool finder_info::open(const std::string &path, open_mode mode, std::error_code
afp_init(&_afp);
if (mode != write_only) {
ec = std::make_error_code(std::errc::illegal_byte_sequence);
return false;
}
if (mode == read_only) return false;
}
return true;
}
@ -483,7 +484,8 @@ bool finder_info::open(const std::wstring &path, open_mode mode, std::error_code
if (ec) {
afp_init(&_afp);
return false;
if (mode == read_only) return false;
return true;
}
// warn if incorrect size or data.
@ -491,8 +493,8 @@ bool finder_info::open(const std::wstring &path, open_mode mode, std::error_code
afp_init(&_afp);
if (mode != write_only) {
ec = std::make_error_code(std::errc::illegal_byte_sequence);
return false;
}
if (mode == read_only) return false;
}
return true;
}
@ -598,7 +600,7 @@ bool finder_info::open(const std::string &path, open_mode mode, std::error_code
// read it...
auto ok = _(::pread(_fd, &_finder_info, 32, 0), ec);
if (mode == read_only) close();
if (ec) return false;
if (ec && mode == read_only) return false;
}
return true;
}
@ -637,7 +639,11 @@ bool finder_info::open(const std::string &path, open_mode mode, std::error_code
if (mode == read_only) close();
if (ec) {
remap_enoattr(ec);
return false;
if (mode == read_only) return false;
if (ec.value() == EOPNOTSUPP) {
close();
return false;
}
}
}
return true;