af_core_macros/
path.rs

1// Copyright © 2020 Alexandra Frydl
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7/// Joins multiple paths together.
8#[macro_export]
9macro_rules! path_join {
10  ($first:expr, $($path:expr),+) => {{
11    let mut path = String::from($first);
12
13    $(af_core::fs::path::push(&mut path, $path);)*
14
15    path
16  }};
17
18  ($path:expr) => {
19    $path
20  };
21}
22
23/// Joins multiple paths together and then normalizes the result.
24#[macro_export]
25macro_rules! path_normalize {
26  ($($args:tt)*) => {
27    af_core::fs::path::normalized(af_core::fs::path::join!($($args:tt)*))
28  };
29}
30
31/// Joins multiple paths together and then resolves the result.
32#[macro_export]
33macro_rules! path_resolve {
34  ($($args:tt)*) => {
35    af_core::fs::path::resolved(af_core::fs::path::join!($($args:tt)*))
36  };
37}