FileRealPath.cpp 584 B

12345678910111213141516171819202122232425
  1. // Copyright (c) 2016-2016 Josh Blum
  2. // SPDX-License-Identifier: BSL-1.0
  3. #include <Pothos/Config.hpp>
  4. #include <cstdio> //FILENAME_MAX
  5. #include <cstdlib> //realpath/_fullpath
  6. #include <string>
  7. /*!
  8. * Resolve the symbolic link.
  9. * This functionality should be in Poco::File
  10. */
  11. std::string Pothos_FileRealPath(const std::string &path)
  12. {
  13. char buff[FILENAME_MAX];
  14. char *result(nullptr);
  15. #ifdef _MSC_VER
  16. result = _fullpath(buff, path.c_str(), sizeof(buff));
  17. #else
  18. result = realpath(path.c_str(), buff);
  19. #endif
  20. return (result != nullptr)?result:path;
  21. }