Doxygen
Loading...
Searching...
No Matches
fswrapper.h File Reference

Selects the filesystem implementation used by doxygen. More...

#include <src/fswrapper.h>

Include dependency graph for fswrapper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

fs::path toFsPath (const std::string &s)
 Converts a UTF-8 encoded string into a path.
std::string fromFsPath (const fs::path &p)
 Converts a path into a UTF-8 encoded string.

Detailed Description

Selects the filesystem implementation used by doxygen.

The standard library's std::filesystem is used when it is available and usable without extra link libraries. Otherwise the bundled ghc::filesystem (deps/filesystem) is used as a fallback, in particular for:

  • GCC 8 / libstdc++ 8 (e.g. RHEL 8), where std::filesystem needs -lstdc++fs
  • LLVM libc++ before version 9, where it needs -lc++fs
  • macOS deployment targets before 10.15, which lack std::filesystem

Defining DOXYGEN_USE_GHC_FILESYSTEM forces the use of ghc::filesystem.

Doxygen uses UTF-8 encoded std::string paths everywhere. ghc::filesystem treats narrow strings as UTF-8 on all platforms, but std::filesystem uses the active (ANSI) code page on Windows. Always convert between strings and paths using toFsPath() and fromFsPath(), so non-ASCII file names keep working on Windows.

Definition in file fswrapper.h.

Function Documentation

◆ fromFsPath()

std::string fromFsPath ( const fs::path & p)
inline

Converts a path into a UTF-8 encoded string.

Definition at line 78 of file fswrapper.h.

79{
80#if DOXYGEN_USE_STD_FILESYSTEM && defined(_WIN32)
81# if defined(__cpp_char8_t)
82 const std::u8string s = p.u8string();
83 return std::string(s.begin(), s.end());
84# else
85 return p.u8string();
86# endif
87#else
88 return p.string();
89#endif
90}

Referenced by FileInfo::absFilePath(), Dir::absPath(), Dir::cleanDirPath(), Dir::currentDirPath(), Dir::exists(), FileInfo::fileName(), Dir::filePath(), Dir::iterator(), Dir::path(), DirEntry::path(), and FileInfo::readLink().

◆ toFsPath()

fs::path toFsPath ( const std::string & s)
inline

Converts a UTF-8 encoded string into a path.

Definition at line 64 of file fswrapper.h.

65{
66#if DOXYGEN_USE_STD_FILESYSTEM && defined(_WIN32)
67# if defined(__cpp_char8_t)
68 return fs::path(std::u8string(s.begin(), s.end()));
69# else
70 return fs::u8path(s);
71# endif
72#else
73 return fs::path(s);
74#endif
75}

Referenced by FileInfo::absFilePath(), Dir::cleanDirPath(), Dir::copy(), Dir::empty(), Dir::exists(), FileInfo::exists(), FileInfo::fileName(), Dir::filePath(), FileInfo::isDir(), FileInfo::isExecutable(), FileInfo::isFile(), FileInfo::isReadable(), FileInfo::isRelative(), Dir::isRelativePath(), FileInfo::isSymLink(), FileInfo::isWritable(), Dir::mkdir(), Portable::openInputStream(), Portable::openOutputStream(), DirIterator::Private::Private(), FileInfo::readLink(), Dir::remove(), Dir::rename(), Dir::setCurrent(), Dir::setPath(), and FileInfo::size().