Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cxong/tinydir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Voronezhskii <Sergey.Voronezhskiy@gmail.com>2018-02-23 02:40:13 +0300
committerCong <congusbongus@gmail.com>2018-02-23 02:40:13 +0300
commit677733daa2859c963da953872f8d591251c2ae5e (patch)
treeeb0cdaaf1f111dce9cf8a4ace792808d81014693
parentc29a016ca6b171fed2fb8906e7e417917f010b59 (diff)
check errno inside tinydir_file_open (fixes #58) (#59)
* check errno inside tinydir_file_open (fixes #58) `_tsplitpath_s` returns errno_t which should to be check instead of `(void) _tsplitpath` * one block for checking errno
-rw-r--r--tinydir.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/tinydir.h b/tinydir.h
index ca71571..324f9f6 100644
--- a/tinydir.h
+++ b/tinydir.h
@@ -658,7 +658,7 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
/* Get the parent path */
#if (defined _MSC_VER || defined __MINGW32__)
#if ((defined _MSC_VER) && (_MSC_VER >= 1400))
- _tsplitpath_s(
+ errno = _tsplitpath_s(
path,
drive_buf, _TINYDIR_DRIVE_MAX,
dir_name_buf, _TINYDIR_FILENAME_MAX,
@@ -673,6 +673,11 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
ext_buf);
#endif
+if (errno)
+{
+ return -1;
+}
+
/* _splitpath_s not work fine with only filename and widechar support */
#ifdef _UNICODE
if (drive_buf[0] == L'\xFEFE')
@@ -681,11 +686,6 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
dir_name_buf[0] = '\0';
#endif
- if (errno)
- {
- errno = EINVAL;
- return -1;
- }
/* Emulate the behavior of dirname by returning "." for dir name if it's
empty */
if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0')