MCPcopy Create free account
hub / github.com/boostorg/filesystem / get_path_max

Function get_path_max

src/directory.cpp:289–317  ·  view source on GitHub ↗

Obtains maximum length of a path, not including the terminating zero

Source from the content-addressed store, hash-verified

287
288// Obtains maximum length of a path, not including the terminating zero
289inline std::size_t get_path_max()
290{
291 // this code is based on Stevens and Rago, Advanced Programming in the
292 // UNIX envirnment, 2nd Ed., ISBN 0-201-43307-9, page 49
293 std::size_t max = 0;
294 errno = 0;
295 long res = ::pathconf("/", _PC_PATH_MAX);
296 if (res < 0)
297 {
298#if defined(PATH_MAX)
299 max = PATH_MAX;
300#else
301 max = 4096;
302#endif
303 }
304 else
305 {
306 max = static_cast< std::size_t >(res); // relative root
307#if defined(PATH_MAX)
308 if (max < PATH_MAX)
309 max = PATH_MAX;
310#endif
311 }
312
313 if ((max + 1) < sizeof(dirent().d_name))
314 max = sizeof(dirent().d_name) - 1;
315
316 return max;
317}
318
319// Returns maximum length of a path, not including the terminating zero
320inline std::size_t path_max()

Callers 1

path_maxFunction · 0.85

Calls 1

direntClass · 0.85

Tested by

no test coverage detected