Quiq/TempDir.pm

filter: Statementstmt 91.6% 33 / 36 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 100% 1 / 1 totaltotal 88.2% 45 / 51 CC 3 SCAR 4.2
CC
3
Cov
88%
new
3.1
BEGIN
1.0
__ANON__
1.0
CRAP 1.5
« Quiq/JQuery/ContextMenu.pm ↑ Summary Quiq/DirHandle.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::TempDir - Temporäres Verzeichnis
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Object>
12  
13 =head1 DESCRIPTION
14  
15 Der Konstruktor der Klasse erzeugt ein temporäres Verzeichnis.
16 Geht die letzte Objekt-Referenz aus dem Scope, wird das Verzeichnis
17 automatisch gelöscht. Das Verzeichnis-Objekt stringifiziert sich
18 im String-Kontext automatisch zum Verzeichnis-Pfad.
19  
20 =cut
21  
22 # -----------------------------------------------------------------------------
23  
24 package Quiq::TempDir;
25 270 ▶use base qw/Quiq::Object/;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 270 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 270 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 270 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 270 our $VERSION = '1.240';
32  
33 0 ▶use overload '""' => sub {${$_[0]}}, 'cmp' => sub{${$_[0]} cmp $_[1]};
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
34 270 ▶use Quiq::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 270 ▶use File::Temp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 # -----------------------------------------------------------------------------
38  
39 =head1 METHODS
40  
41 =head2 Konstruktor
42  
43 =head3 new() - Instantiiere Objekt
44  
45 =head4 Synopsis
46  
47 $dir = $class->new;
48  
49 =head4 Options
50  
51 =over 4
52  
53 =item -cleanup => $bool (Default: 1)
54  
55 Entferne das Verzeichnis bei Beendigung des Programms. Wenn 0, bleibt das
56 Verzeichnis nach Beendigung des Programms bestehen.
57  
58 =item -parentDir => $dir
59  
60 Erzeuge das temporäre Verzeichnis unterhalb von Verzeichnis $dir.
61  
62 =back
63  
64 =head4 Returns
65  
66 Tempverzeichnis-Objekt
67  
68 =head4 Description
69  
70 Instantiiere ein Objekt der Klasse und liefere eine Referenz auf
71 dieses Objekt zurück.
72  
73 =cut
74  
75 # -----------------------------------------------------------------------------
76  
77 3 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod documented
78 3 my $class = shift;
79 # @_: @opt
80  
81 # Optionen und Argumente
82  
83 3 my $cleanup = 1;
84 3 my $parentDir = undef;
85  
86 3 my $argA = $class->parameters(0,0,\@_,
87 -cleanup => \$cleanup,
88 -parentDir => \$parentDir,
89 );
90  
91 # Wir setzen unsere Optionen in die Optionen von File::Temp::newdir() um
92  
93 3 my @args;
94 3 ▶ if (defined $cleanup) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cleanup) 3 0 3
95 3 push @args,'CLEANUP',$cleanup;
96 }
97 3 ▶ if ($parentDir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentDir) 0 3 3
98 0 push @args,'DIR',Quiq::Path->expandTilde($parentDir);
99 }
100  
101 # Objekt instantiieren
102 3 return bless \File::Temp->newdir(@args),$class;
103 }
104  
105 # -----------------------------------------------------------------------------
106  
107 =head1 VERSION
108  
109 1.240
110  
111 =head1 AUTHOR
112  
113 Frank Seitz, L<http://fseitz.de/>
114  
115 =head1 COPYRIGHT
116  
117 Copyright (C) 2026 Frank Seitz
118  
119 =head1 LICENSE
120  
121 This code is free software; you can redistribute it and/or modify
122 it under the same terms as Perl itself.
123  
124 =cut
125  
126 # -----------------------------------------------------------------------------
127  
128 270 1;
129  
130 # eof
« Quiq/JQuery/ContextMenu.pm ↑ Summary Quiq/DirHandle.pm »