| 129 | namespace |
| 130 | { |
| 131 | std::string GetCwd() |
| 132 | { |
| 133 | #ifdef _WIN32 |
| 134 | char path[MAXPATHLEN]; |
| 135 | _getcwd(path, MAXPATHLEN); |
| 136 | return path; |
| 137 | #else |
| 138 | std::vector<char> current_dir; |
| 139 | #ifdef PATH_MAX |
| 140 | current_dir.resize(PATH_MAX); |
| 141 | #else |
| 142 | current_dir.resize(1024); |
| 143 | #endif |
| 144 | while (::getcwd(¤t_dir[0], current_dir.size()) == NULL && errno == ERANGE) { |
| 145 | current_dir.resize(current_dir.size() + 1024); |
| 146 | } |
| 147 | |
| 148 | return std::string(¤t_dir[0]); |
| 149 | #endif |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | std::string AbsPath(const std::string & path) |