migrated http proxy and ws client

This commit is contained in:
JT Smith 2005-01-03 03:24:43 +00:00
parent 15c48e14d0
commit 7416bda04f
14 changed files with 282 additions and 1306 deletions

View file

@ -96,6 +96,29 @@ sub _addError {
}
#-------------------------------------------------------------------
=head2 _makePath ( )
Creates the filesystem folders for a storage location.
NOTE: This is a private method and should never be called except internally to this package.
=cut
sub _makePath {
my $self = shift;
my $node = $session{config}{uploadsPath};
foreach my $folder ($self->{_part1}, $self->{_part2}, $self->{_id}) {
$node .= $session{os}{slash}.$folder;
unless (-e $node) { # check to see if it already exists
unless (mkdir($node)) { # check to see if there was an error during creation
$self->_addError("Couldn't create storage location: $node : $!");
}
}
}
}
#-------------------------------------------------------------------
=head2 addFileFromFilesystem( pathToFile )
@ -292,15 +315,7 @@ sub create {
my $class = shift;
my $id = WebGUI::Id::generate();
my $self = $class->get($id);
my $node = $session{config}{uploadsPath};
foreach my $folder ($self->{_part1}, $self->{_part2}, $id) {
$node .= $session{os}{slash}.$folder;
unless (-e $node) { # check to see if it already exists
unless (mkdir($node)) { # check to see if there was an error during creation
$self->_addError("Couldn't create storage location: $node : $!");
}
}
}
$self->_makePath;
return $self;
}
@ -353,7 +368,10 @@ sub get {
my $class = shift;
my $id = shift;
$id =~ m/^(.{2})(.{2})/;
bless {_id => $id, _part1 => $1, _part2 => $2}, ref($class)||$class;
my $self = {_id => $id, _part1 => $1, _part2 => $2};
bless $self, ref($class)||$class;
$self->_makePath unless (-e $self->getPath); # create the folder in case it got deleted somehow
return $self;
}
#-------------------------------------------------------------------