Lines Matching refs:path

25 # This Perl package helps with path transforming when running curl tests on
30 # (1) /some/path - absolute path in Unix-style
31 # (2) D:/some/path - absolute path in Win32-style
32 # (3) some/path - relative path
33 # (4) D:some/path - path relative to current directory on Win32 drive (paths
35 # (5) \some/path - path from root directory on current Win32 drive (*)
50 # control on Win32 current drive and Win32 current path on specific drive.
104 # Returns boolean true if 'cygpath' utility should be used for path conversion.
116 # Performs path "normalization": all slashes converted to forward
121 # path for not yet existing directory can be "normalized".
173 # Internal function. Converts path by using Msys's built-in transformation.
174 # Returned path may contain duplicated and back slashes.
178 # drive letter ('c'), second optional parameter is path relative to drive's
179 # current working directory. Returns Win32 absolute normalized path.
183 # absolute Unix-style path. Other types of paths are not supported.
190 # Converts given path to system native format, i.e. to Win32 format on
195 my ($path) = @_;
198 return $path if (!os_is_win());
200 # Do not process empty path.
201 return $path if ($path eq '');
203 if($path =~ s{^([a-zA-Z]):$}{\u$1:}) {
207 # Be careful, this relative path can be accidentally transformed
208 # into wrong absolute path by adding to it some '/dirname' with
210 return $path;
212 elsif($path =~ m{^\\} || $path =~ m{^[a-zA-Z]:[^/\\]}) {
214 # path on current directory on specific Win32 drive.
215 # ('\path' or 'D:path')
217 # resolved to absolute path by 'cygpath'.
221 my $first_char = ucfirst(substr($path, 0, 1));
224 $path =~ s{[\\/]+}{/}g;
228 substr($path, 0, 1, $first_char);
229 return $path;
236 $path =~ s{^([\\/])[\\/]+}{$1}g;
238 my $has_final_slash = ($path =~ m{[/\\]$});
240 # Use 'cygpath', '-m' means Win32 path with forward slashes.
241 chomp($path = `cygpath -m '$path'`);
243 warn "Can't convert path by \"cygpath\".\n";
248 $path .= '/' if($has_final_slash);
252 $path =~ s{//+}{/}g;
254 return $path;
257 # Msys transforms automatically path to Windows native form in staring
260 $path = do_msys_transform($path);
261 return undef if !defined $path;
264 $path =~ s{^([a-z]:)}{\u$1};
267 $path =~ s{[\\/]+}{/}g;
268 return $path;
270 elsif($path =~ s{^([a-zA-Z]):[/\\]}{\u$1:/}) {
271 # Path is already in Win32 form. ('C:\path')
274 $path =~ s{[\\/]+}{/}g;
275 return $path;
277 elsif($path !~ m{^/}) {
278 # Path is in relative form. ('path/name', './path' or '../path')
281 $path =~ s{[\\/]+}{/}g;
282 return $path;
285 # OS is Windows, but not Msys, path is absolute, path is not in Win32
287 return do_dumb_guessed_transform($path);
291 # Converts given path to system native absolute path, i.e. to Win32
296 my ($path) = @_;
299 # Convert path to absolute form.
300 $path = Cwd::abs_path($path);
303 return $path;
306 if($path =~ m{^([a-zA-Z]):($|[^/\\].*$)}) {
307 # Path is single drive with colon or relative path on Win32 drive.
308 # ('C:' or 'C:path')
309 # This kind of relative path is not processed correctly by 'cygpath'.
313 elsif($path eq '') {
322 my $has_final_slash = ($path =~ m{[\\/]$});
326 $path =~ s{^([\\/])[\\/]+}{$1}g;
328 print "Inter result: \"$path\"\n";
329 # Use 'cygpath', '-m' means Win32 path with forward slashes,
330 # '-a' means absolute path
331 chomp($path = `cygpath -m -a '$path'`);
333 warn "Can't resolve path by usung \"cygpath\".\n";
338 $path .= '/' if($has_final_slash);
342 $path =~ s{//+}{/}g;
344 return $path
346 elsif($path =~ s{^([a-zA-Z]):[/\\]}{\u$1:/}) {
347 # Path is already in Win32 form. ('C:\path')
351 return normalize_path($path);
353 elsif(substr($path, 0, 1) eq '\\' ) {
359 # Combine drive and path.
362 return normalize_path($w32drive . $path);
365 if(substr($path, 0, 1) ne '/') {
384 $path = $cur_dir . '/' . $path;
388 $path = normalize_path($path);
389 return undef unless defined $path;
392 # Msys transforms automatically path to Windows native form in staring
394 $path = do_msys_transform($path);
395 return undef if !defined $path;
398 $path =~ s{[\\/]+}{/}g;
399 return $path;
401 # OS is Windows, but not Msys, path is absolute, path is not in Win32
404 return do_dumb_guessed_transform($path);
407 # Internal function. Converts given Unix-style absolute path to Win32 format.
411 # Converts given path to build system format absolute path, i.e. to
416 my ($path) = @_;
419 # Convert path to absolute form.
420 $path = Cwd::abs_path($path);
423 return $path;
426 if($path =~ m{^([a-zA-Z]):($|[^/\\].*$)}) {
427 # Path is single drive with colon or relative path on Win32 drive.
428 # ('C:' or 'C:path')
429 # This kind of relative path is not processed correctly by 'cygpath'.
432 # Resolve relative dirs in Win32-style path or paths like 'D:/../c/'
436 $path = get_abs_path_on_win32_drive($1, $2);
437 return undef if !defined $path;
439 return simple_transform_win32_to_unix($path);
441 elsif($path eq '') {
447 chomp($path = `bash -c 'pwd -L'`);
450 chomp($path = `pwd -L`);
458 $path .= '/' if length($path) > 2;
459 return $path;
464 my $has_final_slash = ($path =~ m{[\\/]$});
469 $path = normalize_path($path);
470 return undef if !defined $path;
472 # Use 'cygpath', '-u' means Unix-stile path,
473 # '-a' means absolute path
474 chomp($path = `cygpath -u -a '$path'`);
476 warn "Can't resolve path by usung \"cygpath\".\n";
480 # 'cygpath' removes last slash if path is root dir on Win32 drive.
482 $path .= '/' if($has_final_slash &&
483 substr($path, length($path) - 1, 1) ne '/');
485 return $path
487 elsif($path =~ m{^[a-zA-Z]:[/\\]}) {
488 # Path is already in Win32 form. ('C:\path')
490 # Resolve relative dirs in Win32-style path otherwise paths
494 $path = normalize_path($path);
495 return undef if !defined $path;
497 return simple_transform_win32_to_unix($path);
499 elsif(substr($path, 0, 1) eq '\\') {
505 # Combine drive and path.
506 # Resolve relative dirs in Win32-style path or paths like 'D:/../c/'
510 $path = normalize_path($w32drive . $path);
511 return undef if !defined $path;
513 return simple_transform_win32_to_unix($path);
517 if(substr($path, 0, 1) ne '/') {
536 $path = $cur_dir . '/' . $path;
539 return normalize_path($path);
543 # Performs path "normalization": all slashes converted to forward
548 # path for not yet existing directory can be "normalized".
551 my ($path) = @_;
554 return $path if $path eq '';
556 if($path !~ m{(?:^|\\|/)\.{1,2}(?:\\|/|$)}) {
558 my $first_char = substr($path, 0, 1);
559 $path =~ s{[\\/]+}{/}g;
561 substr($path, 0, 1, $first_char);
562 return $path;
569 # Check whether path starts from Win32 drive. ('C:path' or 'C:\path')
570 if($path =~ m{^([a-zA-Z]:(/|\\)?)(.*$)}) {
573 # Process path separately from drive letter.
579 if($path =~ m{^(\/|\\)}) {
586 @arr = split(m{\/|\\}, $path);
603 warn "Error processing path \"$path\": " .
609 $ret .= '/' if($path =~ m{\\$|/$} && scalar @res > 0);
614 # Internal function. Converts path by using Msys's built-in
617 my ($path) = @_;
619 return $path if $path eq '';
623 $path =~ s{^/[/\\]+}{/};
625 # Msys transforms automatically path to Windows native form in staring
627 # Note: already checked that $path is non-empty.
628 $path = `cmd //c echo '$path'`;
630 warn "Can't transform path into Win32 form by using Msys" .
637 $path =~ s{^\"|\"$|\"\r|\n|\r}{}g;
639 return $path;
643 # drive letter ('c'), second optional parameter is path relative to drive's
644 # current working directory. Returns Win32 absolute normalized path.
668 # Append relative path part.
679 # absolute Unix-style path. Other types of paths are not supported.
684 my ($path) = @_;
688 $path =~ s{[/\\]+}{/}g;
690 # Empty path is not valid.
691 return undef if (length($path) == 0);
698 # Check path whether path is Win32 directly mapped drive and try to
700 if($path =~ m{$drv_ltr_re}) {
705 # This may be some custom mapped path. ('/mymount/path')
707 # Must check longest possible path component as subdir can be mapped to
710 my $check_path = $path;
716 if($? == 0 && substr($path, 0, 1) ne '%') {
739 warn "Can't determine Win32 directory for path \"$path\".\n";
746 # Internal function. Converts given Unix-style absolute path to Win32 format.
748 my ($path) = @_;
753 chomp($res = `cygpath -a -u '$path'`);
756 "directory \"$path\".\n";
760 # 'cygpath' removes last slash if path is root dir on Win32 drive.
762 $path =~ m{[/\\]$});
767 if($path !~ s{^([a-zA-Z]):(?:/|\\)}{/\l$1/}) {
769 "directory \"$path\".\n";
773 $path = '/cygdrive' . $path if(drives_mounted_on_cygdrive());
774 return $path;