Пример #1
0
bool os_can_exe(const char_u *name)
{
  // If it's an absolute or relative path don't need to use $PATH.
  if (path_is_absolute_path(name) ||
     (name[0] == '.' && (name[1] == '/' ||
                        (name[1] == '.' && name[2] == '/')))) {
    return is_executable(name);
  }

  return is_executable_in_path(name);
}
Пример #2
0
/// Checks if the given path represents an executable file.
///
/// @param[in]  name     The name of the executable.
/// @param[out] abspath  Path of the executable, if found and not `NULL`.
///
/// @return `true` if `name` is executable and
///   - can be found in $PATH,
///   - is relative to current dir or
///   - is absolute.
///
/// @return `false` otherwise.
bool os_can_exe(const char_u *name, char_u **abspath)
{
  // If it's an absolute or relative path don't need to use $PATH.
  if (path_is_absolute_path(name) ||
     (name[0] == '.' && (name[1] == '/' ||
                        (name[1] == '.' && name[2] == '/')))) {
    if (is_executable(name)) {
      if (abspath != NULL) {
        *abspath = save_absolute_path(name);
      }

      return true;
    }

    return false;
  }

  return is_executable_in_path(name, abspath);
}
Пример #3
0
Файл: fs.c Проект: hoop33/neovim
/// Checks if the given path represents an executable file.
///
/// @param[in]  name     Name of the executable.
/// @param[out] abspath  Path of the executable, if found and not `NULL`.
/// @param[in] use_path  If 'false', only check if "name" is executable
///
/// @return `true` if `name` is executable and
///   - can be found in $PATH,
///   - is relative to current dir or
///   - is absolute.
///
/// @return `false` otherwise.
bool os_can_exe(const char_u *name, char_u **abspath, bool use_path)
  FUNC_ATTR_NONNULL_ARG(1)
{
  bool no_path = !use_path || path_is_absolute_path(name);
#ifndef WIN32
  // If the filename is "qualified" (relative or absolute) do not check $PATH.
  no_path |= (name[0] == '.'
              && (name[1] == '/' || (name[1] == '.' && name[2] == '/')));
#endif

  if (no_path) {
#ifdef WIN32
    const char *pathext = os_getenv("PATHEXT");
    if (!pathext) {
      pathext = ".com;.exe;.bat;.cmd";
    }
    bool ok = is_executable((char *)name) || is_executable_ext((char *)name,
                                                               pathext);
#else