From 80d1ec57d103278b056c5f0552af861bb730a1a4 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 27 Jul 2019 01:08:22 +1000 Subject: [PATCH] Fix HasFile and HasDirectory --- stratosphere/ncm/source/ncm_contentstorage.cpp | 3 ++- stratosphere/ncm/source/ncm_fs.cpp | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/stratosphere/ncm/source/ncm_contentstorage.cpp b/stratosphere/ncm/source/ncm_contentstorage.cpp index cf399c4a1..40734f2ab 100644 --- a/stratosphere/ncm/source/ncm_contentstorage.cpp +++ b/stratosphere/ncm/source/ncm_contentstorage.cpp @@ -127,8 +127,9 @@ namespace sts::ncm { } Result ContentStorageInterface::HasPlaceHolder(Out out, PlaceHolderId placeholder_id) { - if (this->disabled) + if (this->disabled) { return ResultNcmInvalidContentStorage; + } char placeholder_path[FS_MAX_PATH] = {0}; this->placeholder_accessor.GetPlaceHolderPath(placeholder_path, placeholder_id); diff --git a/stratosphere/ncm/source/ncm_fs.cpp b/stratosphere/ncm/source/ncm_fs.cpp index 4de2822ad..e9d4aa721 100644 --- a/stratosphere/ncm/source/ncm_fs.cpp +++ b/stratosphere/ncm/source/ncm_fs.cpp @@ -25,12 +25,14 @@ namespace sts::ncm { errno = 0; struct stat st; - *out = false; if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { *out = true; + } else { + *out = false; } - if (errno != 0) { + /* It is a valid state for the file to not exist. */ + if (errno != 0 && errno != ENOENT && errno != ENOTDIR) { return fsdevGetLastResult(); } @@ -41,12 +43,14 @@ namespace sts::ncm { errno = 0; struct stat st; - *out = false; if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { *out = true; + } else { + *out = false; } - if (errno != 0) { + /* It is a valid state for the directory to not exist. */ + if (errno != 0 && errno != ENOENT && errno != ENOTDIR) { return fsdevGetLastResult(); }