| 1 | package Geo::GDAL::FFI::VSI; | ||||||||||||||||||||
| 2 | 13 | ▶ | use v5.10; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 13 | ▶ | use Encode qw(decode encode); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 13 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 13 | ▶ | use FFI::Platypus::Buffer; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 13 | require Exporter; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 13 | our $VERSION = '0.15'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 13 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 13 | 13 | our @EXPORT_OK = qw(Mkdir Rmdir ReadDir FOpen Unlink Rename); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | sub FOpen { | ||||||||||||||||||||
| 16 | 0 | ▶ | return Geo::GDAL::FFI::VSI::File->Open(@_); | ||||||||||||||||||
|
Subroutine
FOpen: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | sub Unlink { | ||||||||||||||||||||
| 20 | 0 | ▶ | my ($path) = @_; | ||||||||||||||||||
|
Subroutine
Unlink: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 21 | 0 | my $e = Geo::GDAL::FFI::VSIUnlink(encode(utf8 => $path)); | |||||||||||||||||||
| 22 | 0 | ▶ | confess Geo::GDAL::FFI::error_msg() // "Failed to unlink '$path'." if $e == -1; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
Geo::GDAL::FFI::error_msg() // "Failed to unlink '${path}'."
MC/DC0%0/1
Geo::GDAL::FFI::error_msg() // "Failed to unlink '${path}'."
Geo::GDAL::FFI::error_msg()
Truth table0%0/2
A
A= Geo::GDAL::FFI::error_msg()
| |||||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | sub Rename { | ||||||||||||||||||||
| 26 | 0 | ▶ | my ($path, $new_path) = @_; | ||||||||||||||||||
|
Subroutine
Rename: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 27 | 0 | my $e = Geo::GDAL::FFI::VSIRename(encode(utf8 => $path), encode(utf8 => $new_path)); | |||||||||||||||||||
| 28 | 0 | ▶ | confess Geo::GDAL::FFI::error_msg() // "Failed to rename '$path' to '$new_path'." if $e == -1; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
Geo::GDAL::FFI::error_msg() // "Failed to rename '${path}' to '${new_path}'."
MC/DC0%0/1
Geo::GDAL::FFI::error_msg() // "Failed to rename '${path}' to '${new_path}'."
Geo::GDAL::FFI::error_msg()
Truth table0%0/2
A
A= Geo::GDAL::FFI::error_msg()
| |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | sub Mkdir { | ||||||||||||||||||||
| 32 | 0 | ▶ | my ($path, $mode) = @_; | ||||||||||||||||||
|
Subroutine
Mkdir: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 33 | 0 | ▶ | $mode //= hex '0x0666'; | ||||||||||||||||||
|
Condition0%0/2
$mode //= 1638
MC/DC0%0/1
$mode //= 1638
$mode
Truth table0%0/2
A
A= $mode
| |||||||||||||||||||||
| 34 | 0 | my $e = Geo::GDAL::FFI::VSIMkdir(encode(utf8 => $path), $mode); | |||||||||||||||||||
| 35 | 0 | ▶ | confess Geo::GDAL::FFI::error_msg() // "Failed to mkdir '$path'." if $e == -1; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
Geo::GDAL::FFI::error_msg() // "Failed to mkdir '${path}'."
MC/DC0%0/1
Geo::GDAL::FFI::error_msg() // "Failed to mkdir '${path}'."
Geo::GDAL::FFI::error_msg()
Truth table0%0/2
A
A= Geo::GDAL::FFI::error_msg()
| |||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | sub Rmdir { | ||||||||||||||||||||
| 39 | 0 | ▶ | my ($path) = @_; | ||||||||||||||||||
|
Subroutine
Rmdir: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 40 | 0 | my $e = Geo::GDAL::FFI::VSIRmdir(encode(utf8 => $path)); | |||||||||||||||||||
| 41 | 0 | ▶ | confess Geo::GDAL::FFI::error_msg() // "Failed to rmdir '$path'." if $e == -1; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
Geo::GDAL::FFI::error_msg() // "Failed to rmdir '${path}'."
MC/DC0%0/1
Geo::GDAL::FFI::error_msg() // "Failed to rmdir '${path}'."
Geo::GDAL::FFI::error_msg()
Truth table0%0/2
A
A= Geo::GDAL::FFI::error_msg()
| |||||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | sub ReadDir { | ||||||||||||||||||||
| 45 | 0 | ▶ | my ($path, $max_files) = @_; | ||||||||||||||||||
|
Subroutine
ReadDir: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 46 | 0 | ▶ | $max_files //= 0; | ||||||||||||||||||
|
Condition0%0/2
$max_files //= 0
MC/DC0%0/1
$max_files //= 0
$max_files
Truth table0%0/2
A
A= $max_files
| |||||||||||||||||||||
| 47 | 0 | my $csl = Geo::GDAL::FFI::VSIReadDirEx(encode(utf8 => $path), $max_files); | |||||||||||||||||||
| 48 | 0 | my @dir; | |||||||||||||||||||
| 49 | 0 | for my $i (0 .. Geo::GDAL::FFI::CSLCount($csl)-1) { | |||||||||||||||||||
| 50 | 0 | push @dir, decode utf8 => Geo::GDAL::FFI::CSLGetField($csl, $i); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | 0 | Geo::GDAL::FFI::CSLDestroy($csl); | |||||||||||||||||||
| 53 | 0 | return @dir; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 13 | 1; | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =pod | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | =encoding UTF-8 | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head1 NAME | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | Geo::GDAL::FFI::VSI - A GDAL virtual file system | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =head1 SYNOPSIS | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | use Geo::GDAL::FFI::VSI qw/FOpen Mkdir ReadDir/; | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =head1 DESCRIPTION | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =head1 METHODS | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | =head2 FOpen($path, $access) | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | my $file = FOpen('/vsimem/file', 'w'); | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | Short for Geo::GDAL::FFI::VSI::File::Open | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =head2 Mkdir($path, $mode) | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | $mode is optional and by default 0x0666. | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =head2 ReadDir($path, $max_files) | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | $max_files is optional and by default 0, i.e., read all names of files | ||||||||||||||||||||
| 87 | in the dir. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =head1 LICENSE | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | This software is released under the Artistic License. See | ||||||||||||||||||||
| 92 | L<perlartistic>. | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =head1 AUTHOR | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | Ari Jolma - Ari.Jolma at gmail.com | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =head1 SEE ALSO | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | L<Geo::GDAL::FFI> | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | L<Alien::gdal>, L<FFI::Platypus>, L<http://www.gdal.org> | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | __END__; | ||||||||||||||||||||