|
| 1 | +// Copyright (C) 2020 Matthew "strager" Glazar |
| 2 | +// See end of file for extended copyright information. |
| 3 | + |
| 4 | +#ifndef QUICK_LINT_JS_FILE_CANONICAL_H |
| 5 | +#define QUICK_LINT_JS_FILE_CANONICAL_H |
| 6 | + |
| 7 | +#include <string> |
| 8 | + |
| 9 | +namespace quick_lint_js { |
| 10 | +class canonical_path_result { |
| 11 | + public: |
| 12 | + explicit canonical_path_result(std::string &&path); |
| 13 | + explicit canonical_path_result(const char *path); |
| 14 | + |
| 15 | + std::string_view path() const &noexcept; |
| 16 | + std::string &&path() && noexcept; |
| 17 | + const char *c_str() const noexcept; |
| 18 | + |
| 19 | + std::string &&error() && noexcept; |
| 20 | + |
| 21 | + bool ok() const noexcept { return this->error_.empty(); } |
| 22 | + |
| 23 | + static canonical_path_result failure(std::string &&error); |
| 24 | + |
| 25 | + private: |
| 26 | + explicit canonical_path_result(); |
| 27 | + |
| 28 | + std::string path_; |
| 29 | + std::string error_; |
| 30 | +}; |
| 31 | + |
| 32 | +canonical_path_result canonicalize_path(const char *path); |
| 33 | +canonical_path_result canonicalize_path(const std::string &path); |
| 34 | +} |
| 35 | + |
| 36 | +#endif |
| 37 | + |
| 38 | +// quick-lint-js finds bugs in JavaScript programs. |
| 39 | +// Copyright (C) 2020 Matthew "strager" Glazar |
| 40 | +// |
| 41 | +// This file is part of quick-lint-js. |
| 42 | +// |
| 43 | +// quick-lint-js is free software: you can redistribute it and/or modify |
| 44 | +// it under the terms of the GNU General Public License as published by |
| 45 | +// the Free Software Foundation, either version 3 of the License, or |
| 46 | +// (at your option) any later version. |
| 47 | +// |
| 48 | +// quick-lint-js is distributed in the hope that it will be useful, |
| 49 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 50 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 51 | +// GNU General Public License for more details. |
| 52 | +// |
| 53 | +// You should have received a copy of the GNU General Public License |
| 54 | +// along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>. |
0 commit comments