mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-30 22:45:17 -04:00
errno begone
This commit is contained in:
parent
65b7ac9039
commit
8f65beef78
5 changed files with 65 additions and 105 deletions
|
@ -142,10 +142,7 @@ namespace sts::ncm {
|
|||
}
|
||||
|
||||
struct stat st;
|
||||
errno = 0;
|
||||
stat(content_path, &st);
|
||||
|
||||
if (errno != 0) {
|
||||
if (stat(content_path, &st) == -1) {
|
||||
return fsdevGetLastResult();
|
||||
}
|
||||
|
||||
|
@ -186,23 +183,21 @@ namespace sts::ncm {
|
|||
path::GetContentMetaPath(content_path, content_id, this->make_content_path_func, this->root_path);
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
FILE* f = fopen(content_path, "rb");
|
||||
|
||||
ON_SCOPE_EXIT {
|
||||
fclose(f);
|
||||
};
|
||||
|
||||
if (f == NULL || errno != 0) {
|
||||
if (f == nullptr) {
|
||||
return fsdevGetLastResult();
|
||||
}
|
||||
|
||||
if (!fseek(f, offset, SEEK_SET)) {
|
||||
return fsdevGetLastResult();
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
fseek(f, offset, SEEK_SET);
|
||||
fread(buf.buffer, buf.num_elements, 1, f);
|
||||
|
||||
if (errno != 0) {
|
||||
return fsdevGetLastResult();
|
||||
if (fread(buf.buffer, 1, buf.num_elements, f) != buf.num_elements && ferror(f)) {
|
||||
return fsdevGetLastResult();
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue