File tree 3 files changed +68
-5
lines changed
3 files changed +68
-5
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // Licensed under the Apache License v2.0 with LLVM Exceptions.
3
+ // See https://llvm.org/LICENSE.txt for license information.
4
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
+ //
6
+ // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
7
+ //
8
+ // Official repository: https://github.com/cppalliance/mrdox
9
+ //
10
+
11
+ #ifndef MRDOX_SUPPORT_PATH_HPP
12
+ #define MRDOX_SUPPORT_PATH_HPP
13
+
14
+ #include < mrdox/Platform.hpp>
15
+ #include < string>
16
+ #include < string_view>
17
+
18
+ namespace clang {
19
+ namespace mrdox {
20
+
21
+ /* * Return a full path from a possibly relative path.
22
+ */
23
+ std::string
24
+ makeFullPath (
25
+ std::string_view pathName,
26
+ std::string_view workingDir);
27
+
28
+ } // mrdox
29
+ } // clang
30
+
31
+ #endif
Original file line number Diff line number Diff line change 10
10
//
11
11
12
12
#include " Path.hpp"
13
+ #include < llvm/Support/FileSystem.h>
14
+ #include < llvm/Support/Path.h>
13
15
14
16
namespace clang {
15
17
namespace mrdox {
16
18
19
+ // ------------------------------------------------
20
+
21
+ std::string
22
+ makeFullPath (
23
+ std::string_view pathName,
24
+ std::string_view workingDir)
25
+ {
26
+ namespace path = llvm::sys::path;
27
+
28
+ llvm::SmallString<0 > result;
29
+
30
+ if (! path::is_absolute (pathName))
31
+ {
32
+ result = workingDir;
33
+ path::append (result, path::Style ::posix, pathName);
34
+ path::remove_dots (result, true , path::Style ::posix);
35
+ return std::string (result);
36
+ }
37
+
38
+ result = pathName;
39
+ path::remove_dots (result, true );
40
+ convert_to_slash (result);
41
+ return std::string (result);
42
+ }
43
+
44
+
45
+ // ------------------------------------------------
46
+
17
47
llvm::StringRef
18
48
convert_to_slash (
19
49
llvm::SmallVectorImpl<char > &path,
Original file line number Diff line number Diff line change 19
19
namespace clang {
20
20
namespace mrdox {
21
21
22
- // / Replaces backslashes with slashes if Windows in place.
23
- // /
24
- // / @param path A path that is transformed to native format.
25
- // / On Unix, this function is a no-op because backslashes
26
- // / are valid path chracters.
22
+ /* * Replaces backslashes with slashes if Windows in place.
23
+
24
+ @param path A path that is transformed to native format.
25
+
26
+ On Unix, this function is a no-op because backslashes
27
+ are valid path chracters.
28
+ */
27
29
llvm::StringRef
28
30
convert_to_slash (
29
31
llvm::SmallVectorImpl<char > &path,
You can’t perform that action at this time.
0 commit comments