Eulerian/EDW/File.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 39 CC 1 SCAR 6.9
CC
1
Cov
0%
read
2.0
writable
2.0
BEGIN
2.0
CRAP 2.0
1 #/usr/bin/env perl
2 ###############################################################################
3 #
4 # @file File.pm
5 #
6 # @brief API::Eulerian::EDW::File module used to manage local file system.
7 #
8 # @author Thorillon Xavier:x.thorillon@eulerian.com
9 #
10 # @date 25/11/2021
11 #
12 # @version 1.0
13 #
14 ###############################################################################
15 #
16 # Setup perl package name
17 #
18 package API::Eulerian::EDW::File;
19 #
20 # Enforce compilor rules
21 #
22 use strict; use warnings;
23 #
24 # Import API::Eulerian::EDW::Status
25 #
26 use API::Eulerian::EDW::Status;
27 #
28 # @brief Read file content.
29 #
30 # @param path - File path.
31 #
32 # @return API::Eulerian::EDW::Status
33 #
34 sub read
35 {
36 my $status = API::Eulerian::EDW::Status->new();
37 my ( $class, $path ) = @_;
38 my $data;
39 my $fd;
40 # Open file for reading
41 open $fd, "<", $path or do {
42 $status->error( 1 );
43 $status->code( -1 );
44 $status->msg( "Opening file : $path for reading failed. $!" );
45 return $status;
46 };
47 # Read file content
48 $data = do { local $/; <$fd> };
49 # Close file
50 close $fd;
51 # Save content
52 $status->{ data } = $data;
53 return $status;
54 }
55 #
56 # @brief Test if given path is writable.
57 #
58 # @param $class - API::Eulerian::EDW::File class.
59 # @param $path - Filesystem path.
60 #
61 # @return 0 - Path isnt writable.
62 # @return 1 - Path is writable.
63 #
64 sub writable
65 {
66 my ( $class, $path ) = @_;
67 return -w $path;
68 }
69 #
70 # End up perl module properly
71 #
72 1;
73  
74 __END__