mirror of
https://github.com/ksherlock/afp.git
synced 2025-01-02 15:29:21 +00:00
open will return true w/ error if non-fatal error reading but fd still valid
This commit is contained in:
parent
e2f1cb0b4b
commit
d7660c16cc
@ -441,7 +441,8 @@ bool finder_info::open(const std::string &path, open_mode mode, std::error_code
|
|||||||
|
|
||||||
if (ec) {
|
if (ec) {
|
||||||
afp_init(&_afp);
|
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.
|
// 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);
|
afp_init(&_afp);
|
||||||
if (mode != write_only) {
|
if (mode != write_only) {
|
||||||
ec = std::make_error_code(std::errc::illegal_byte_sequence);
|
ec = std::make_error_code(std::errc::illegal_byte_sequence);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
if (mode == read_only) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -483,7 +484,8 @@ bool finder_info::open(const std::wstring &path, open_mode mode, std::error_code
|
|||||||
|
|
||||||
if (ec) {
|
if (ec) {
|
||||||
afp_init(&_afp);
|
afp_init(&_afp);
|
||||||
return false;
|
if (mode == read_only) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// warn if incorrect size or data.
|
// 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);
|
afp_init(&_afp);
|
||||||
if (mode != write_only) {
|
if (mode != write_only) {
|
||||||
ec = std::make_error_code(std::errc::illegal_byte_sequence);
|
ec = std::make_error_code(std::errc::illegal_byte_sequence);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
if (mode == read_only) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -598,7 +600,7 @@ bool finder_info::open(const std::string &path, open_mode mode, std::error_code
|
|||||||
// read it...
|
// read it...
|
||||||
auto ok = _(::pread(_fd, &_finder_info, 32, 0), ec);
|
auto ok = _(::pread(_fd, &_finder_info, 32, 0), ec);
|
||||||
if (mode == read_only) close();
|
if (mode == read_only) close();
|
||||||
if (ec) return false;
|
if (ec && mode == read_only) return false;
|
||||||
}
|
}
|
||||||
return true;
|
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 (mode == read_only) close();
|
||||||
if (ec) {
|
if (ec) {
|
||||||
remap_enoattr(ec);
|
remap_enoattr(ec);
|
||||||
return false;
|
if (mode == read_only) return false;
|
||||||
|
if (ec.value() == EOPNOTSUPP) {
|
||||||
|
close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user