diff options
author | Maarten Vanraes <alien@mageia.org> | 2016-02-03 00:28:32 +0100 |
---|---|---|
committer | Maarten Vanraes <alien@mageia.org> | 2016-05-14 09:25:23 +0200 |
commit | 2b728d13638299a2505f9e90b7d5cf597e36f22d (patch) | |
tree | b96e539b00e88944c56c3d006d679e81fae40ddf | |
parent | f241e33a63c7c2d68dacefb2e37fdce62d2f0e7b (diff) | |
download | manatools-2b728d13638299a2505f9e90b7d5cf597e36f22d.tar manatools-2b728d13638299a2505f9e90b7d5cf597e36f22d.tar.gz manatools-2b728d13638299a2505f9e90b7d5cf597e36f22d.tar.bz2 manatools-2b728d13638299a2505f9e90b7d5cf597e36f22d.tar.xz manatools-2b728d13638299a2505f9e90b7d5cf597e36f22d.zip |
add a FileSystem Role
-rw-r--r-- | lib/ManaTools/Shared/disk_backend/FileSystem.pm | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/disk_backend/FileSystem.pm b/lib/ManaTools/Shared/disk_backend/FileSystem.pm new file mode 100644 index 00000000..b7b58305 --- /dev/null +++ b/lib/ManaTools/Shared/disk_backend/FileSystem.pm @@ -0,0 +1,126 @@ +# vim: set et ts=4 sw=4: +package ManaTools::Shared::disk_backend::FileSystem; + +#============================================================= -*-perl-*- + +=head1 NAME + + ManaTools::Shared::disk_backend::FileSystem - a FileSystem Moose Role + +=head1 SYNOPSIS + package Foo; + + with 'ManaTools::Shared::disk_backend::FileSystem'; + + 1; + + ... + + my $f = Foo->new(); + my $in = $f->fsprobe($io); + + +=head1 DESCRIPTION + + This Role is an collection of FileSystem in the backend to manadisk + +=head1 SUPPORT + + You can find documentation for this Role with the perldoc command: + + perldoc ManaTools::Shared::disk_backend::FileSystem + + +=head1 AUTHOR + + Maarten Vanraes <alien@rmail.be> + +=head1 COPYRIGHT and LICENSE + +Copyright (c) 2015 Maarten Vanraes <alien@rmail.be> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2, as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +=head1 METHODS + +=cut + +use Moose::Role; + +#============================================================= + +=head2 fsprobe + +=head3 INPUT + + $io: ManaTools::Shared::disk_backend::IO + +=head3 OUTPUT + + ManaTools::Shared::disk_backend::IO or undef + +=head3 DESCRIPTION + + this method probes the IO to see if it fits for this + filesystem, if it does, create a new Part with this IO as in. + also create an IO (linked as the out) and return that one. + The resulting one can then be used as an in to eg: a Mount Part. + +=cut + +#============================================================= + +requires 'fsprobe'; + +has 'fstypes' => ( + is => 'ro', + isa => 'ArrayRef[Str]', + init_arg => undef, + default => sub { return []; }, +); + +#============================================================= + +=head2 has_type + +=head3 INPUT + + $type: Str + +=head3 OUTPUT + + 1 | 0 + +=head3 DESCRIPTION + + this method checks if this particular plugin can handle + the given filesystem. + +=cut + +#============================================================= + +sub has_type { + my $self = shift; + my $type = shift; + my $fstypes = $self->fstypes(); + for my $t (@{$fstypes}) { + if ($t eq $type) { + return 1; + } + } + return 0; +} + +1; |