diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-03-23 15:29:40 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-03-23 15:29:40 +0000 |
commit | 9f1a11f6213832fc9c7a715c0510068856f56564 (patch) | |
tree | ae3d66a2ab6245ae849832290b97e1ad7d2b1618 /perl-install/common.pm | |
parent | dc9b2dc6c7c81edf9b0663d1436dff417246e038 (diff) | |
download | drakx-backup-do-not-use-9f1a11f6213832fc9c7a715c0510068856f56564.tar drakx-backup-do-not-use-9f1a11f6213832fc9c7a715c0510068856f56564.tar.gz drakx-backup-do-not-use-9f1a11f6213832fc9c7a715c0510068856f56564.tar.bz2 drakx-backup-do-not-use-9f1a11f6213832fc9c7a715c0510068856f56564.tar.xz drakx-backup-do-not-use-9f1a11f6213832fc9c7a715c0510068856f56564.zip |
(openFileMaybeCompressed, catMaybeCompressed): added
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r-- | perl-install/common.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm index 4c75bd91e..5e53de15b 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -8,7 +8,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int %EXPORT_TAGS = ( common => [ qw(__ may_apply even odd arch better_arch compat_arch min max sqr sum and_ or_ if_ if__ sign product bool invbool listlength bool2text bool2yesno text2bool to_int to_float ikeys member divide is_empty_array_ref is_empty_hash_ref add2hash add2hash_ put_in_hash set_new set_add round round_up round_down first second top uniq translate untranslate warp_text formatAlaTeX formatLines deref next_val_in_array) ], functional => [ qw(fold_left compose mapgrep map_index grep_index find_index map_each grep_each list2kv map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie combine) ], - file => [ qw(dirname basename touch all glob_ cat_ cat__ output symlinkf renamef chop_ mode typeFromMagic expand_symlinks) ], + file => [ qw(dirname basename touch all glob_ cat_ cat__ catMaybeCompressed output symlinkf renamef chop_ mode typeFromMagic expand_symlinks) ], system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ salt getVarsFromSh setVarsInSh setVarsInShMode setVarsInCsh substInFile availableMemory availableRamMB removeXiBSuffix formatXiB template2file template2userfile update_userkderc list_skels formatTime formatTimeRaw unix2dos setVirtual isCdNotEjectable) ], constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE %compat_arch) ], ); @@ -112,6 +112,14 @@ sub sync { syscall_('sync') } sub gettimeofday { my $t = pack "LL"; syscall_('gettimeofday', $t, 0) or die "gettimeofday failed: $!\n"; unpack("LL", $t) } sub unix2dos { local $_ = $_[0]; s/\015$//mg; s/$/\015/mg; $_ } +sub openFileMaybeCompressed { + my ($f) = @_; + -e $f || -e "$f.gz" or die "file $f not found"; + open F, -e $f ? $f : "gzip -dc $f.gz|"; + *F; +} +sub catMaybeCompressed { cat__(openFileMaybeCompressed($_[0])) } + sub remove_spaces { local $_ = shift; s/^ +//; s/ +$//; $_ } sub mode { my @l = stat $_[0] or die "unable to get mode of file $_[0]: $!\n"; $l[2] } sub psizeof { length pack $_[0] } |