🛰️航天仿真算法库 SpaceAST 0.3.1
载入中...
搜索中...
未找到
PosixExt.hpp
浏览该文件的文档.
1
22
23#pragma once
24
25#include "AstGlobal.h"
26#include "Posix.hpp"
27#include <string>
28#include <limits>
29
30AST_NAMESPACE_BEGIN
31
37namespace posix
38{
39#if defined(PATH_MAX)
40constexpr size_t kMaxPath = PATH_MAX;
41#elif defined (MAX_PATH)
42constexpr size_t kMaxPath = MAX_PATH;
43#elif defined(_MAX_PATH)
44constexpr size_t kMaxPath = _MAX_PATH;
45#elif defined(_POSIX_PATH_MAX)
46constexpr size_t kMaxPath = _POSIX_PATH_MAX;
47#else
48constexpr size_t kMaxPath = 255; // default max path length
49#endif
50
53 A_ALWAYS_INLINE std::string getcwd()
54 {
55 char buffer[kMaxPath];
56 if (posix::getcwd(buffer, sizeof(buffer)) != nullptr) {
57 return buffer;
58 }
59 return std::string();
60 }
61#if defined(_WIN32) || defined(AST_PARSED_BY_DOXYGEN)
65 A_ALWAYS_INLINE
66 bool isdir(const stat& st)
67 {
68 return (_S_IFDIR & st.st_mode) != 0;
69 }
70#else
71 A_ALWAYS_INLINE
72 bool isdir(const struct stat& st)
73 {
74 return S_ISDIR(st.st_mode);
75 }
76#endif
77}
78
81AST_NAMESPACE_END
AST_UTIL_API char * getcwd(char *buf, size_t size)
获取当前工作目录
A_ALWAYS_INLINE bool isdir(const stat &st)
检查文件状态是否为目录
定义 PosixExt.hpp:66