• R/O
  • SSH

libctools: Commit

This library contains code that extends and simplifies different operations
for C language based programs.


Commit MetaInfo

Revisión98c616898d07b64a66c28248cad5dc0c137510b8 (tree)
Tiempo2017-10-07 07:48:27
Autors.gusarov
Commiters.gusarov

Log Message

io.c: Local constant kLimit was renamed to kPathLimit and made a global one.

Cambiar Resumen

Diferencia incremental

diff -r 678a1dda1296 -r 98c616898d07 include/ctools/os/io.h
--- a/include/ctools/os/io.h Sat Oct 07 01:27:56 2017 +0300
+++ b/include/ctools/os/io.h Sat Oct 07 01:48:27 2017 +0300
@@ -41,6 +41,14 @@
4141 # endif
4242 /* *INDENT-ON* */
4343
44+/**
45+ * @brief Some large enough value that represents limits in the path.
46+ *
47+ * This constant can be used when we know that length of file system object
48+ * will be much less than absolute value(~250).
49+ */
50+const size_t kPathLimit;
51+
4452 extern bool isFileExists(const char* const name) CT_NOEXCEPT;
4553
4654 /**
diff -r 678a1dda1296 -r 98c616898d07 src/os/io.c
--- a/src/os/io.c Sat Oct 07 01:27:56 2017 +0300
+++ b/src/os/io.c Sat Oct 07 01:48:27 2017 +0300
@@ -45,6 +45,8 @@
4545
4646 CT_BEGIN_NAMESPACE
4747
48+const size_t kPathLimit = PATH_MAX;
49+
4850 /*
4951 * We could include stdlib.h for realpath() but on some systems(i.e. Ubuntu 14.04)
5052 * stdlib.h(->features.h) undefines everything
@@ -92,6 +94,8 @@
9294
9395 CT_BEGIN_NAMESPACE
9496
97+const size_t kPathLimit = _MAX_PATH;
98+
9599 char* getAbsolutePath(const char* const path, char* resolvedPath, const size_t bufferSize) CT_NOEXCEPT
96100 {
97101 /*
@@ -179,17 +183,9 @@
179183
180184 static CT_FORCEINLINE char* copyPathString(const char* const path) CT_NOEXCEPT
181185 {
182-# ifdef CT_OS_WINDOWS
183- const size_t kLimit = _MAX_PATH;
184-# elif defined CT_OS_UNIX
185- const size_t kLimit = PATH_MAX;
186-# else
187-# error Unimplemented at all
188-# endif
189-
190186 CT_USING_CT_NAMESPACE
191187
192- char* kPathCopy = strndup(path, kLimit);
188+ char* kPathCopy = strndup(path, kPathLimit);
193189
194190 return kPathCopy;
195191 }
Show on old repository browser