-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Windows path manipulation and other cleanups (#2801)
* Add path_win_to_posix * Move path_has_drive_letter and is_path * Refactor on_[plat] * Add util::path_to_posix * Fix static builds
- Loading branch information
1 parent
cf3e20e
commit 3fcff39
Showing
29 changed files
with
319 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2023, QuantStack and Mamba Contributors | ||
// | ||
// Distributed under the terms of the BSD 3-Clause License. | ||
// | ||
// The full license is in the file LICENSE, distributed with this software. | ||
|
||
#ifndef MAMBA_UTIL_BUILD_HPP | ||
#define MAMBA_UTIL_BUILD_HPP | ||
|
||
namespace mamba::util | ||
{ | ||
#if __APPLE__ || __MACH__ | ||
inline static constexpr bool on_win = false; | ||
inline static constexpr bool on_linux = false; | ||
inline static constexpr bool on_mac = true; | ||
#elif __linux__ | ||
inline static constexpr bool on_win = false; | ||
inline static constexpr bool on_linux = true; | ||
inline static constexpr bool on_mac = false; | ||
#elif _WIN32 | ||
inline static constexpr bool on_win = true; | ||
inline static constexpr bool on_linux = false; | ||
inline static constexpr bool on_mac = false; | ||
#else | ||
#error "no supported OS detected" | ||
#endif | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2023, QuantStack and Mamba Contributors | ||
// | ||
// Distributed under the terms of the BSD 3-Clause License. | ||
// | ||
// The full license is in the file LICENSE, distributed with this software. | ||
|
||
#ifndef MAMBA_UTIL_PATH_MANIP_HPP | ||
#define MAMBA_UTIL_PATH_MANIP_HPP | ||
|
||
#include <string> | ||
#include <string_view> | ||
|
||
namespace mamba::util | ||
{ | ||
inline static constexpr char preferred_path_separator_posix = '/'; | ||
inline static constexpr char preferred_path_separator_win = '\\'; | ||
|
||
/** | ||
* Return true is the input is explicitly a path. | ||
* | ||
* Explicit path are: | ||
* - Absolute path | ||
* - Path starting with '~' | ||
* - Relative paths starting with "./" or "../" | ||
*/ | ||
[[nodiscard]] auto is_explicit_path(std::string_view input) -> bool; | ||
|
||
/** | ||
* Check if a Windows path (not URL) starts with a drive letter. | ||
*/ | ||
[[nodiscard]] auto path_has_drive_letter(std::string_view path) -> bool; | ||
|
||
/** | ||
* Convert the Windows path separators to Posix ones. | ||
*/ | ||
[[nodiscard]] auto path_win_to_posix(std::string path) -> std::string; | ||
|
||
/** | ||
* Convert the Windows path separators to Posix ones on Windows only. | ||
*/ | ||
[[nodiscard]] auto path_to_posix(std::string path) -> std::string; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.