File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4848#include " pcrepp/pcre2pp.hh"
4949#include " scn/scan.h"
5050#include " short_alloc.h"
51+ #include " string_util.hh"
5152
5253#ifdef HAVE_LIBPROC_H
5354# include < libproc.h>
5455#endif
5556
5657namespace lnav ::filesystem {
5758
59+ static bool have_cygdrive ()
60+ {
61+ static const auto RETVAL = access (" /cygdrive" , X_OK ) == 0 ;
62+
63+ return RETVAL ;
64+ }
65+
5866std::string
5967escape_glob_for_win (std::string arg)
6068{
@@ -237,6 +245,9 @@ path_transcoder::from(std::string arg)
237245 }
238246
239247 arg.insert (arg.begin (), ' /' );
248+ if (have_cygdrive ()) {
249+ arg.insert (0 , " /cygdrive" );
250+ }
240251 std::replace (arg.begin (), arg.end (), ' \\ ' , ' /' );
241252
242253 return {arg, caps};
@@ -249,7 +260,15 @@ path_transcoder::to_native(std::string arg)
249260 return arg;
250261 }
251262
252- arg.erase (0 , 1 );
263+ static const auto CYGDRIVE = " /cygdrive" _frag;
264+
265+ if (startswith (arg, CYGDRIVE .data ())) {
266+ arg.erase (0 , CYGDRIVE .length ());
267+ }
268+
269+ if (arg[0 ] == ' /' ) {
270+ arg.erase (0 , 1 );
271+ }
253272 if (this ->pt_root_name_capitalized .value ()) {
254273 arg[0 ] = toupper (arg[0 ]);
255274 }
You can’t perform that action at this time.
0 commit comments