This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=99a7e9b29d2078f8978d3738af82b93296ac9046 commit 99a7e9b29d2078f8978d3738af82b93296ac9046 Author: Guillem Jover <guil...@debian.org> AuthorDate: Wed Oct 26 20:19:12 2022 +0200 Dpkg::File: Add new file_touch() function --- scripts/Dpkg/File.pm | 8 ++++++++ scripts/t/Dpkg_File.t | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/Dpkg/File.pm b/scripts/Dpkg/File.pm index 316198989..dd3fd9f2c 100644 --- a/scripts/Dpkg/File.pm +++ b/scripts/Dpkg/File.pm @@ -23,6 +23,7 @@ our $VERSION = '0.01'; our @EXPORT = qw( file_slurp file_dump + file_touch ); use Exporter qw(import); @@ -68,4 +69,11 @@ sub file_dump { return; } +sub file_touch { + my $file = shift; + + open my $fh, '>', $file or syserr(g_('cannot create file %s'), $file); + close $fh or syserr(g_('cannot write %s'), $file); +} + 1; diff --git a/scripts/t/Dpkg_File.t b/scripts/t/Dpkg_File.t index 5ed187acd..bbc6a3b3b 100644 --- a/scripts/t/Dpkg_File.t +++ b/scripts/t/Dpkg_File.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 10; use Test::Dpkg qw(:paths); use File::Compare; @@ -72,4 +72,9 @@ eval { }; ok($@, 'cannot slurp missing file'); +ok(! -e "$tempdir/touched", 'file to be touched does not exist'); +file_touch("$tempdir/touched"); +ok(-e "$tempdir/touched", 'touched file exists'); +ok(-z "$tempdir/touched", 'touched file is empty'); + 1; -- Dpkg.Org's dpkg