- Timestamp:
- Jun 25, 2009, 2:00:56 PM (17 years ago)
- Location:
- branches/eam_branches/20090522
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
Nebulous-Server (modified) (1 prop)
-
Nebulous-Server/lib/Nebulous/Key.pm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090522
- Property svn:mergeinfo changed
-
branches/eam_branches/20090522/Nebulous-Server
- Property svn:mergeinfo changed
-
branches/eam_branches/20090522/Nebulous-Server/lib/Nebulous/Key.pm
r23932 r24557 8 8 use warnings FATAL => qw( all ); 9 9 10 our $VERSION = '0.0 2';10 our $VERSION = '0.03'; 11 11 12 12 use base qw( Exporter Class::Accessor::Fast ); … … 14 14 use File::Spec; 15 15 use URI::file; 16 use Carp qw( croak ); 16 17 use URI; 17 18 use overload '""' => \&_stringify_key; … … 22 23 ); 23 24 24 __PACKAGE__->mk_ro_accessors(qw( path volume soft_volume ));25 __PACKAGE__->mk_ro_accessors(qw( path volume hard_volume )); 25 26 26 27 sub parse_neb_key 27 28 { 28 29 my ($key, $volume) = @_; 29 return unless defined $key; 30 31 croak "key param is not optional" unless defined $key; 32 croak "too many params" if scalar @_ > 2; 30 33 31 34 # white space is not allowed 32 35 if ($key =~ qr/\s+/) { 33 die"keys and URIs may not contain whitespace";36 croak "keys and URIs may not contain whitespace"; 34 37 } 35 38 … … 39 42 40 43 my $volume_name; 41 my $ soft_volume;44 my $hard_volume; 42 45 # if this is a valid uri 43 46 if (defined $scheme) { 44 47 # if so, does it use the neb scheme? 45 die"URI does not use the 'neb' scheme"48 croak "URI does not use the 'neb' scheme" 46 49 unless $scheme eq 'neb'; 47 50 … … 58 61 # path component to it 59 62 unless (length $path) { 60 die"neb URI scheme requires a path component";63 croak "neb URI scheme requires a path component"; 61 64 } 62 65 … … 68 71 if (defined $volume_info->{volume} and $volume_info->{volume} ne 'any') { 69 72 $volume_name = $volume_info->{volume}; 70 $ soft_volume = $volume_info->{soft_volume};73 $hard_volume = $volume_info->{hard_volume}; 71 74 } 72 75 73 76 # require a leading slash if there is no volume name 74 77 if ((not defined $volume_name) and (not $path =~ m|^/|)) { 75 die"neb URI scheme requires a leading slash, eg. neb:/";78 croak "neb URI scheme requires a leading slash, eg. neb:/"; 76 79 } 77 80 } else { … … 81 84 if (defined $volume_info->{volume} and $volume_info->{volume} ne 'any') { 82 85 $volume_name = $volume_info->{volume}; 83 $ soft_volume = $volume_info->{soft_volume};86 $hard_volume = $volume_info->{hard_volume}; 84 87 } 85 88 } … … 96 99 return __PACKAGE__->new({ 97 100 volume => $volume_name, 98 soft_volume => $soft_volume,101 hard_volume => $hard_volume, 99 102 path => $path, 100 103 }); … … 107 110 return unless defined $volume; 108 111 109 my $ soft_volume;112 my $hard_volume; 110 113 # check to see if there is a tilde and remove it if found 111 unless(defined $volume and $volume =~ s/^~//) {112 $ soft_volume = 1;114 if (defined $volume and $volume =~ s/^~//) { 115 $hard_volume = 1; 113 116 } 114 117 115 return({ volume => $volume, soft_volume => $soft_volume });118 return({ volume => $volume, hard_volume => $hard_volume }); 116 119 } 117 120 … … 122 125 123 126 my $path = $self->path; 124 my $volume = $self->volume || "";125 my $ soft_volume = $self->soft_volume ? '~' : "";126 127 return "neb://${ soft_volume}${volume}/$path";127 my $volume = $self->volume || ''; 128 my $hard_volume = $self->hard_volume ? '~' : ''; 129 130 return "neb://${hard_volume}${volume}/$path"; 128 131 } 129 132
Note:
See TracChangeset
for help on using the changeset viewer.
