Sys/Env.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 package SPVM::Sys::Env;
2  
3 1;
4  
5 =head1 Name
6  
7 SPVM::Sys::Env - Environemnt Variables
8  
9 =head1 Description
10  
11 The C<Sys::Env> class in L<SPVM> has methods to manipulate environemnt variables.
12  
13 =head1 Usage
14  
15 use Sys::Env;
16
17 my $path = Sys::Env->getenv("PATH");
18
19 Sys::Env->setenv("PATH", "/foo/bar");
20  
21 =head1 Class Methods
22  
23 =head2 getenv
24  
25 C<static method getenv : string ($name : string);>
26  
27 Calls the L<getenv|https://linux.die.net/man/3/getenv> function and copy its return value and returns it.
28  
29 Exceptions:
30  
31 $name must be defined. Otherwise an exception is thrown.
32  
33 =head2 setenv
34  
35 C<static method setenv : int ($name : string, $value : string, $overwrite : int);>
36  
37 Calls the L<setenv|https://linux.die.net/man/3/setenv> function and returns its return value.
38  
39 Exceptions:
40  
41 $name must be defined. Otherwise an exception is thrown.
42  
43 $value must be defined. Otherwise an exception is thrown.
44  
45 If setenv failed, an exception is thrown and C<eval_error_id> is set to the basic type ID of the L<Error::System|SPVM::Error::System>.
46  
47 In Windows the following exception is thrown. setenv is not supported in this system(defined(_WIN32)).
48  
49 =head2 unsetenv
50  
51 C<static method unsetenv : int ($name : string);>
52  
53 Calls the L<unsetenv|https://linux.die.net/man/3/unsetenv> function and returns its return value.
54  
55 Exceptions:
56  
57 $name must be defined. Otherwise an exception is thrown.
58  
59 If unsetenv failed, an exception is thrown and C<eval_error_id> is set to the basic type ID of the L<Error::System|SPVM::Error::System>.
60  
61 In Windows the following exception is thrown. unsetenv is not supported in this system(defined(_WIN32)).
62  
63 =head2 _putenv_s
64  
65 C<static method _putenv_s : int ($name : string, $value : string);>
66  
67 Calls the L<_putenv_s|https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s?view=msvc-170> function and returns its return value.
68  
69 Exceptions:
70  
71 $name must be defined. Otherwise an exception is thrown.
72  
73 $value must be defined. Otherwise an exception is thrown.
74  
75 If _putenv_s failed, an exception is thrown and C<eval_error_id> is set to the basic type ID of the L<Error::System|SPVM::Error::System>.
76  
77 In OSs ohter than Windows the following exception is thrown. _putenv_s is not supported in this system(!defined(_WIN32)).
78  
79 =head1 See Also
80  
81 =over 2
82  
83 =item * L<Sys|SPVM::Sys>
84  
85 =back
86  
87 =head1 Copyright & License
88  
89 Copyright (c) 2023 Yuki Kimoto
90  
91 MIT License
92