Command.h 678 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DeprecatedString.h>
  8. #include <AK/LexicalPath.h>
  9. #include <AK/Optional.h>
  10. #include <spawn.h>
  11. namespace Core {
  12. // If the executed command fails, the returned String will be in the null state.
  13. struct CommandResult {
  14. int exit_code { 0 };
  15. DeprecatedString output;
  16. DeprecatedString error;
  17. };
  18. ErrorOr<CommandResult> command(DeprecatedString const& program, Vector<DeprecatedString> const& arguments, Optional<LexicalPath> chdir);
  19. ErrorOr<CommandResult> command(DeprecatedString const& command_string, Optional<LexicalPath> chdir);
  20. }