exe_path.h 773 B

12345678910111213141516171819202122
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_COMMON_EXE_PATH_H_
  5. #define CARBON_COMMON_EXE_PATH_H_
  6. #include "llvm/ADT/StringRef.h"
  7. namespace Carbon {
  8. // Computes the executable path for the given `argv[0]` value from `main`.
  9. // `argv0` is required to be null-terminated.
  10. //
  11. // A simplistic approach -- if the provided string isn't already a valid path,
  12. // we look it up in the PATH environment variable. Doesn't resolve any symlinks
  13. // and if it fails, returns the main executable path.
  14. auto FindExecutablePath(const char* argv0) -> std::string;
  15. } // namespace Carbon
  16. #endif // CARBON_COMMON_EXE_PATH_H_