| 1 | # | ||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||
| 3 | # | ||
| 4 | # vim: set ts=3 sw=3 tw=0: | ||
| 5 | # vim: set expandtab: | ||
| 6 | |||
| 7 | package Rex::Endpoint::HTTP::Interface::Fs::Windows; | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use warnings; | ||
| 11 | |||
| 12 | use Rex::Endpoint::HTTP::Interface::Fs::Base; | ||
| 13 | use base qw(Rex::Endpoint::HTTP::Interface::Fs::Base); | ||
| 14 | |||
| 15 | sub new { | ||
| 16 | my $that = shift; | ||
| 17 | my $proto = ref($that) || $that; | ||
| 18 | my $self = $proto->SUPER::new(@_); | ||
| 19 | |||
| 20 | bless($self, $proto); | ||
| 21 | |||
| 22 | return $self; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub ln { | ||
| 26 | my ($self, $from, $to) = @_; | ||
| 27 | die("Symlink is not implemented on this platform."); | ||
| 28 | } | ||
| 29 | |||
| 30 | sub rmdir { | ||
| 31 | my ($self, $path) = @_; | ||
| 32 | |||
| 33 | system("rd /Q /S " . $path); | ||
| 34 | |||
| 35 | if($? == 0) { | ||
| 36 | return 1; | ||
| 37 | } | ||
| 38 | |||
| 39 | die("Error deleting directory."); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub chown { | ||
| 43 | my ($self, $user, $file, $options) = @_; | ||
| 44 | die("Not implemented on this platform."); | ||
| 45 | } | ||
| 46 | |||
| 47 | sub chgrp { | ||
| 48 | my ($self, $group, $file, $options) = @_; | ||
| 49 | die("Not implemented on this platform."); | ||
| 50 | } | ||
| 51 | |||
| 52 | sub chmod { | ||
| 53 | my ($self, $mode, $file, $options) = @_; | ||
| 54 | die("Not implemented on this platform."); | ||
| 55 | } | ||
| 56 | |||
| 57 | sub cp { | ||
| 58 | my ($self, $source, $dest) = @_; | ||
| 59 | |||
| 60 | system("xcopy /E /C /I /H /K /O /Y $source $dest"); | ||
| 61 | |||
| 62 | if($? == 0) { | ||
| 63 | return 1; | ||
| 64 | } | ||
| 65 | |||
| 66 | die("Error copying file"); | ||
| 67 | } | ||
| 68 | |||
| 69 | sub rename { | ||
| 70 | my ($self, $old, $new) = @_; | ||
| 71 | |||
| 72 | system("move $old $new >/dev/null 2>&1"); | ||
| 73 | |||
| 74 | if($? == 0) { return 1; } | ||
| 75 | } | ||
| 76 | |||
| 77 | 1; |