Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.3 KiB

  1. package URI::file::Base;
  2. use strict;
  3. use URI::Escape qw();
  4. sub new
  5. {
  6. my $class = shift;
  7. my $path = shift;
  8. $path = "" unless defined $path;
  9. my($auth, $escaped_auth, $escaped_path);
  10. ($auth, $escaped_auth) = $class->extract_authority($path);
  11. ($path, $escaped_path) = $class->extract_path($path);
  12. if (defined $auth) {
  13. $auth =~ s,%,%25,g unless $escaped_auth;
  14. $auth =~ s,([/?\#]),$URI::Escape::escapes{$1},g;
  15. $auth = "//$auth";
  16. if (defined $path) {
  17. $path = "/$path" unless substr($path, 0, 1) eq "/";
  18. } else {
  19. $path = "";
  20. }
  21. } else {
  22. return unless defined $path;
  23. $auth = "";
  24. }
  25. $path =~ s,([%;?]),$URI::Escape::escapes{$1},g unless $escaped_path;
  26. $path =~ s/\#/%23/g;
  27. my $uri = $auth . $path;
  28. $uri = "file:$uri" if substr($uri, 0, 1) eq "/";
  29. URI->new($uri, "file");
  30. }
  31. sub extract_authority
  32. {
  33. undef;
  34. }
  35. sub extract_path
  36. {
  37. undef;
  38. }
  39. sub is_this_host
  40. {
  41. shift; # class
  42. my $host = lc(shift);
  43. return 1 if $host eq "localhost";
  44. eval {
  45. require Net::Domain;
  46. lc(Net::Domain::hostfqdn()) eq $host ||
  47. lc(Net::Domain::hostname()) eq $host;
  48. };
  49. }
  50. sub file
  51. {
  52. undef;
  53. }
  54. sub dir
  55. {
  56. my $self = shift;
  57. $self->file(@_);
  58. }
  59. 1;