diff options
author | Sergei Voronezhskii <Sergey.Voronezhskiy@gmail.com> | 2018-02-23 02:40:13 +0300 |
---|---|---|
committer | Cong <congusbongus@gmail.com> | 2018-02-23 02:40:13 +0300 |
commit | 677733daa2859c963da953872f8d591251c2ae5e (patch) | |
tree | eb0cdaaf1f111dce9cf8a4ace792808d81014693 | |
parent | c29a016ca6b171fed2fb8906e7e417917f010b59 (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.h | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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') |