|
1 | 1 | //! Collection of path-related helpers. |
2 | 2 |
|
3 | | -use std::panic; |
4 | 3 | use std::path::{Path, PathBuf}; |
5 | 4 |
|
6 | | -use crate::command::Command; |
7 | 5 | use crate::env::env_var; |
8 | | -use crate::util::handle_failed_output; |
9 | 6 |
|
10 | 7 | /// Return the current working directory. |
11 | 8 | /// |
@@ -34,33 +31,3 @@ pub fn path<P: AsRef<Path>>(p: P) -> PathBuf { |
34 | 31 | pub fn source_root() -> PathBuf { |
35 | 32 | env_var("SOURCE_ROOT").into() |
36 | 33 | } |
37 | | - |
38 | | -/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is |
39 | | -/// available on the platform! |
40 | | -/// |
41 | | -/// # FIXME |
42 | | -/// |
43 | | -/// FIXME(jieyouxu): we should consider not depending on `cygpath`. |
44 | | -/// |
45 | | -/// > The cygpath program is a utility that converts Windows native filenames to Cygwin POSIX-style |
46 | | -/// > pathnames and vice versa. |
47 | | -/// > |
48 | | -/// > [irrelevant entries omitted...] |
49 | | -/// > |
50 | | -/// > `-w, --windows print Windows form of NAMEs (C:\WINNT)` |
51 | | -/// > |
52 | | -/// > -- *from [cygpath documentation](https://cygwin.com/cygwin-ug-net/cygpath.html)*. |
53 | | -#[track_caller] |
54 | | -#[must_use] |
55 | | -pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String { |
56 | | - let caller = panic::Location::caller(); |
57 | | - let mut cygpath = Command::new("cygpath"); |
58 | | - cygpath.arg("-w"); |
59 | | - cygpath.arg(path.as_ref()); |
60 | | - let output = cygpath.run(); |
61 | | - if !output.status().success() { |
62 | | - handle_failed_output(&cygpath, output, caller.line()); |
63 | | - } |
64 | | - // cygpath -w can attach a newline |
65 | | - output.stdout_utf8().trim().to_string() |
66 | | -} |
0 commit comments