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:
authorLautis Sun <lautis0503@gmail.com>2016-09-07 19:12:13 +0300
committerGitHub <noreply@github.com>2016-09-07 19:12:13 +0300
commitd4d5eb2d07762457096f602d8fa2ffaa81397b10 (patch)
treeef3be259d7c20c96b21f47ad9fa9dbb115cc2f92
parent2887d68125cbcc0ca0ce0602b13079254cadf06e (diff)
Define _TINYDIR_PATH_MAX as OS supports
-rw-r--r--tinydir.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/tinydir.h b/tinydir.h
index 8f6d1b5..bc6c2bb 100644
--- a/tinydir.h
+++ b/tinydir.h
@@ -84,15 +84,27 @@ extern "C" {
#define _tinydir_strncmp strncmp
#endif
-#define _TINYDIR_PATH_MAX 4096
+#if (defined _MSC_VER || defined __MINGW32__)
+#include <windows.h>
+#define PATH_MAX MAX_PATH
+#elif defined __linux__
+#include <linux/limits.h>
+#endif
+#define _TINYDIR_PATH_MAX PATH_MAX
+
#ifdef _MSC_VER
/* extra chars for the "\\*" mask */
# define _TINYDIR_PATH_EXTRA 2
#else
# define _TINYDIR_PATH_EXTRA 0
#endif
+
#define _TINYDIR_FILENAME_MAX 256
+#if (defined _MSC_VER || defined __MINGW32__)
+#define _TINYDIR_DRIVE_MAX 3
+#endif
+
#ifdef _MSC_VER
# define _TINYDIR_FUNC static __inline
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
@@ -626,7 +638,7 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
#if ((defined _MSC_VER) && (_MSC_VER >= 1400))
_tsplitpath_s(
path,
- drive_buf, _TINYDIR_PATH_MAX,
+ drive_buf, _TINYDIR_DRIVE_MAX,
dir_name_buf, _TINYDIR_PATH_MAX,
file_name_buf, _TINYDIR_FILENAME_MAX,
ext_buf, sizeof _TINYDIR_FILENAME_MAX);