File tree 2 files changed +39
-0
lines changed
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 31
31
#include < stack>
32
32
#include < stdexcept>
33
33
#include < string>
34
+ #include < sys/stat.h>
34
35
#if __cplusplus >= 201103L
35
36
#ifdef SIMPLECPP_WINDOWS
36
37
#include < mutex>
40
41
#include < utility>
41
42
#include < vector>
42
43
44
+ #ifdef _WIN32
45
+ using mode_t = unsigned short ;
46
+ #else
47
+ #include < sys/types.h>
48
+ #endif
49
+
43
50
#ifdef SIMPLECPP_WINDOWS
44
51
#include < windows.h>
45
52
#undef ERROR
@@ -4006,6 +4013,24 @@ std::string simplecpp::getCppStdString(const std::string &std)
4006
4013
return getCppStdString (getCppStd (std));
4007
4014
}
4008
4015
4016
+ static mode_t file_type (const std::string &path)
4017
+ {
4018
+ struct stat file_stat;
4019
+ if (stat (path.c_str (), &file_stat) == -1 )
4020
+ return 0 ;
4021
+ return file_stat.st_mode & S_IFMT;
4022
+ }
4023
+
4024
+ bool simplecpp::isFile (const std::string &path)
4025
+ {
4026
+ return file_type (path) == S_IFREG;
4027
+ }
4028
+
4029
+ bool simplecpp::isDirectory (const std::string &path)
4030
+ {
4031
+ return file_type (path) == S_IFDIR;
4032
+ }
4033
+
4009
4034
#if (__cplusplus < 201103L) && !defined(__APPLE__)
4010
4035
#undef nullptr
4011
4036
#endif
Original file line number Diff line number Diff line change @@ -391,6 +391,20 @@ namespace simplecpp {
391
391
/* * Returns the __cplusplus value for a given standard */
392
392
SIMPLECPP_LIB std::string getCppStdString (const std::string &std);
393
393
SIMPLECPP_LIB std::string getCppStdString (cppstd_t std);
394
+
395
+ /* *
396
+ * @brief Checks if given path is a file
397
+ * @param path Path to be checked
398
+ * @return true if given path is a file
399
+ */
400
+ SIMPLECPP_LIB bool isFile (const std::string &path);
401
+
402
+ /* *
403
+ * @brief Checks if a given path is a directory
404
+ * @param path Path to be checked
405
+ * @return true if given path is a directory
406
+ */
407
+ SIMPLECPP_LIB bool isDirectory (const std::string &path);
394
408
}
395
409
396
410
#if defined(_MSC_VER)
You can’t perform that action at this time.
0 commit comments