From 0e7b5edc54da6a0e38a06677a47ae5e717f3e0a6 Mon Sep 17 00:00:00 2001 From: Lautis Sun Date: Tue, 19 Jul 2016 09:47:51 +0800 Subject: Fix unicode support in tinydir_file_open --- tinydir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinydir.h b/tinydir.h index 0a9da0c..23ea703 100644 --- a/tinydir.h +++ b/tinydir.h @@ -645,7 +645,7 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path) empty */ if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0') { - strcpy(dir_name_buf, "."); + _tinydir_strcpy(dir_name_buf, TINYDIR_STRING(".")); } /* Concatenate the drive letter and dir name to form full dir name */ _tinydir_strcat(drive_buf, dir_name_buf); -- cgit v1.2.3 From 4b25fece7efcf3880b3a9746a4bf90c32667a9a4 Mon Sep 17 00:00:00 2001 From: Lautis Sun Date: Tue, 19 Jul 2016 10:01:43 +0800 Subject: Test if a unicode string is empty --- tinydir.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tinydir.h b/tinydir.h index 23ea703..d99ced2 100644 --- a/tinydir.h +++ b/tinydir.h @@ -643,7 +643,11 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path) } /* Emulate the behavior of dirname by returning "." for dir name if it's empty */ +#if ((defined _MSC_VER || defined __MINGW32__) && (defined UNICODE)) + if (drive_buf[0] == '\0' && drive_buf[1] == '\0' && dir_name_buf[0] == '\0' && dir_name_buf[1] == '\0') +#else if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0') +#endif { _tinydir_strcpy(dir_name_buf, TINYDIR_STRING(".")); } -- cgit v1.2.3 From d1575e1285224a575e5a2ba345bcfc85c3344cf8 Mon Sep 17 00:00:00 2001 From: Lautis Sun Date: Tue, 19 Jul 2016 10:03:45 +0800 Subject: Replace & with && in line 36&40 Should look good --- tinydir.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinydir.h b/tinydir.h index d99ced2..0a17736 100644 --- a/tinydir.h +++ b/tinydir.h @@ -33,11 +33,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif -#if ((defined _UNICODE) & !(defined UNICODE)) +#if ((defined _UNICODE) && !(defined UNICODE)) #define UNICODE #endif -#if ((defined UNICODE) & !(defined _UNICODE)) +#if ((defined UNICODE) && !(defined _UNICODE)) #define _UNICODE #endif -- cgit v1.2.3