aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-01-20 09:16:55 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-01-20 09:28:52 +0200
commite975c3fd84c4b23b653b286739d6be4f05b0a972 (patch)
tree210b86e107b8a1241a0b563f97ad3b24bc7d7c97
parent4e1f50027c7d6fc59d47d932a2a37860e928ebb5 (diff)
downloadfile-backup-e975c3fd84c4b23b653b286739d6be4f05b0a972.tar.gz
file-backup-e975c3fd84c4b23b653b286739d6be4f05b0a972.tar.bz2
Rename package to File::BackupCopy
-rw-r--r--Makefile.PL6
-rw-r--r--lib/File/BackupCopy.pm (renamed from lib/File/Backup.pm)110
-rw-r--r--t/00simple.t14
-rw-r--r--t/01numbered.t12
-rw-r--r--t/02auto.t18
-rw-r--r--t/03backup.t28
-rw-r--r--t/04envar.t4
7 files changed, 96 insertions, 96 deletions
diff --git a/Makefile.PL b/Makefile.PL
index 84b1f32..1947389 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -6,5 +6,5 @@ use Module::Metadata;
WriteMakefile(
- NAME => 'File::Backup',
- VERSION_FROM => 'lib/File/Backup.pm',
- ABSTRACT_FROM => 'lib/File/Backup.pm',
+ NAME => 'File::BackupCopy',
+ VERSION_FROM => 'lib/File/BackupCopy.pm',
+ ABSTRACT_FROM => 'lib/File/BackupCopy.pm',
LICENSE => 'gpl_3',
diff --git a/lib/File/Backup.pm b/lib/File/BackupCopy.pm
index 3bc18aa..b762e03 100644
--- a/lib/File/Backup.pm
+++ b/lib/File/BackupCopy.pm
@@ -1,2 +1,2 @@
-package File::Backup;
+package File::BackupCopy;
use strict;
@@ -19,5 +19,5 @@ our @EXPORT = qw(BACKUP_NONE
BACKUP_AUTO
- backup);
+ backup_copy);
-our @EXPORT_OK = qw(backup_simple backup_numbered backup_auto);
+our @EXPORT_OK = qw(backup_copy_simple backup_copy_numbered backup_copy_auto);
@@ -45,8 +45,8 @@ my %backup_func = (
BACKUP_NONE() => sub {},
- BACKUP_SIMPLE() => \&backup_simple,
- BACKUP_NUMBERED() => \&backup_numbered,
- BACKUP_AUTO() => \&backup_auto
+ BACKUP_SIMPLE() => \&backup_copy_simple,
+ BACKUP_NUMBERED() => \&backup_copy_numbered,
+ BACKUP_AUTO() => \&backup_copy_auto
);
-sub backup {
+sub backup_copy {
my $file = shift;
@@ -74,3 +74,12 @@ sub backup {
-sub backup_simple {
+sub _backup_copy_error {
+ my ($error, $msg) = @_;
+ if ($error) {
+ $$error = $msg;
+ return undef;
+ }
+ confess $msg;
+}
+
+sub backup_copy_simple {
my $file_name = shift;
@@ -85,3 +94,3 @@ sub backup_simple {
copy($file_name, $backup_name)
- or return _backup_error($error,
+ or return _backup_copy_error($error,
"failed to copy $file_name to $backup_name: $!");
@@ -90,12 +99,3 @@ sub backup_simple {
-sub _backup_error {
- my ($error, $msg) = @_;
- if ($error) {
- $$error = $msg;
- return undef;
- }
- confess $msg;
-}
-
-sub backup_numbered_opt {
+sub backup_copy_internal {
my $file_name = shift;
@@ -117,3 +117,3 @@ sub backup_numbered_opt {
if ($@) {
- return _backup_error($error, $@);
+ return _backup_copy_error($error, $@);
}
@@ -121,3 +121,3 @@ sub backup_numbered_opt {
copy($file_name, $fh)
- or return _backup_error($error,
+ or return _backup_copy_error($error,
"failed to make a temporary copy of $file_name: $!");
@@ -136,3 +136,3 @@ sub backup_numbered_opt {
if (!defined($num)) {
- return backup_simple($file_name, error => $error, dir => $dir)
+ return backup_copy_simple($file_name, error => $error, dir => $dir)
if $if_exists;
@@ -149,3 +149,3 @@ sub backup_numbered_opt {
unless ($!{EEXIST}) {
- return _backup_error("can't link "
+ return _backup_copy_error("can't link "
. $fh->filename .
@@ -157,3 +157,3 @@ sub backup_numbered_opt {
unless (rename($fh->filename, $backup_name)) {
- return _backup_error("can't rename temporary file to $backup_name: $!");
+ return _backup_copy_error("can't rename temporary file to $backup_name: $!");
}
@@ -162,12 +162,12 @@ sub backup_numbered_opt {
-sub backup_numbered {
+sub backup_copy_numbered {
my ($file_name, %opts) = @_;
$opts{if_exists} = 0;
- backup_numbered_opt($file_name, %opts);
+ backup_copy_internal($file_name, %opts);
}
-sub backup_auto {
+sub backup_copy_auto {
my ($file_name, %opts) = @_;
$opts{if_exists} = 1;
- backup_numbered_opt($file_name, %opts);
+ backup_copy_internal($file_name, %opts);
}
@@ -179,3 +179,3 @@ __END__
-File::Backup - create a backup of the file.
+File::BackupCopy - create a backup copy of the file.
@@ -183,9 +183,9 @@ File::Backup - create a backup of the file.
- use File::Backup;
+ use File::BackupCopy;
- $backup_name = backup($file_name);
+ $backup_name = backup_copy($file_name);
- $backup_name = backup($file_name, BACKUP_NUMBERED);
+ $backup_name = backup_copy($file_name, BACKUP_NUMBERED);
- $backup_name = backup($file_name, type => BACKUP_NUMBERED,
+ $backup_name = backup_copy($file_name, type => BACKUP_NUMBERED,
dir => $directory, error => \my $error);
@@ -197,3 +197,3 @@ File::Backup - create a backup of the file.
-The File::Backup module provides functions for creating backup copies of
+The File::BackupCopy module provides functions for creating backup copies of
files. Normally, the name of the backup copy is created by appending a
@@ -203,14 +203,14 @@ scheme, the name of the backup is created by suffixing the original file
name with C<.~I<N>~>, where I<N> is a decimal number starting with 1.
-In this backup naming scheme, the backup copies of file F<test> would be
+In this naming scheme, the backup copies of file F<test> would be
called F<test.~1~>, F<test.~2~> and so on.
-=head2 backup
+=head2 backup_copy
- $backup_name = backup($orig_name);
+ $backup_name = backup_copy($orig_name);
- $backup_name = backup($orig_name, $scheme);
+ $backup_name = backup_copy($orig_name, $scheme);
- $backup_name = backup($orig_name, %opts);
+ $backup_name = backup_copy($orig_name, %opts);
-The B<backup> function is the principal interface for managing backup
+The B<backup_copy> function is the principal interface for managing backup
copies. Its first argument specifies the name of the existing file for
@@ -279,5 +279,5 @@ equivalent:
- backup($file, type => BACKUP_SIMPLE)
+ backup_copy($file, type => BACKUP_SIMPLE)
- backup($file, BACKUP_SIMPLE)
+ backup_copy($file, BACKUP_SIMPLE)
@@ -298,5 +298,5 @@ This can be used for an elaborate error handling and recovery, e.g.:
- $bname = backup($file, \my $err);
+ $bname = backup_copy($file, \my $err);
unless ($bname && defined($err)) {
- error("can't backup file $file: $err");
+ error("can't backup_copy file $file: $err");
# perhaps more code follows
@@ -310,15 +310,15 @@ scheme. These functions must be exported explicitly.
-=head2 backup_simple
+=head2 backup_copy_simple
- use File::Backup qw(backup_simple);
- $backup_name = backup_simple($orig_name, %opts);
+ use File::BackupCopy qw(backup_copy_simple);
+ $backup_name = backup_copy_simple($orig_name, %opts);
Creates simple backup. Optional I<%opts> have the same meaning as in
-B<backup>, except that, obviously, B<type> keyword is not accepted.
+B<backup_copy>, except that, obviously, B<type> keyword is not accepted.
-=head2 backup_numbered
+=head2 backup_copy_numbered
- use File::Backup qw(backup_numbered);
- $backup_name = backup_numbered($orig_name, %opts);
+ use File::BackupCopy qw(backup_copy_numbered);
+ $backup_name = backup_copy_numbered($orig_name, %opts);
@@ -326,6 +326,6 @@ Creates numbered backup. See above for a description of I<%opts>.
-=head2 backup_auto
+=head2 backup_copy_auto
- use File::Backup qw(backup_auto);
- $backup_name = backup_auto($orig_name, %opts);
+ use File::BackupCopy qw(backup_copy_auto);
+ $backup_name = backup_copy_auto($orig_name, %opts);
@@ -335,3 +335,3 @@ the file. Otherwise, creates simple backup.
Optional I<%opts> have the same meaning as in
-B<backup>, except that, obviously, B<type> keyword is not accepted.
+B<backup_copy>, except that, obviously, B<type> keyword is not accepted.
diff --git a/t/00simple.t b/t/00simple.t
index bf4f71a..10faef6 100644
--- a/t/00simple.t
+++ b/t/00simple.t
@@ -4,3 +4,3 @@ use strict;
use TestBackup;
-use File::Backup qw(backup_simple);
+use File::BackupCopy qw(backup_copy_simple);
@@ -10,3 +10,3 @@ makefile('a');
-my $name = backup_simple('a');
+my $name = backup_copy_simple('a');
ok($name, 'a~');
@@ -14,3 +14,3 @@ fileok('a', $name);
-$name = backup_simple('a');
+$name = backup_copy_simple('a');
ok($name, 'a~');
@@ -19,3 +19,3 @@ fileok('a', $name);
mkdir "subdir";
-$name = backup_simple('a', dir => 'subdir');
+$name = backup_copy_simple('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a~'));
@@ -24,3 +24,3 @@ fileok('a', $name);
eval {
- backup_simple('a', dir => 'nonexisting');
+ backup_copy_simple('a', dir => 'nonexisting');
};
@@ -28,3 +28,3 @@ ok(!!$@);
-$name = backup_simple('a', dir => 'nonexisting', error => \my $err);
+$name = backup_copy_simple('a', dir => 'nonexisting', error => \my $err);
ok(!defined($name));
@@ -33,3 +33,3 @@ ok(defined($err) && $err ne '');
# chmod 0, 'subdir';
-# $name = backup_simple('a', dir => 'subdir', error => \$err);
+# $name = backup_copy_simple('a', dir => 'subdir', error => \$err);
# ok(!defined($name));
diff --git a/t/01numbered.t b/t/01numbered.t
index c4cd06a..50572c8 100644
--- a/t/01numbered.t
+++ b/t/01numbered.t
@@ -4,3 +4,3 @@ use strict;
use TestBackup;
-use File::Backup qw(backup_numbered);
+use File::BackupCopy qw(backup_copy_numbered);
@@ -10,3 +10,3 @@ makefile('a');
-my $name = backup_numbered('a');
+my $name = backup_copy_numbered('a');
ok($name, 'a.~1~');
@@ -14,3 +14,3 @@ fileok('a', $name);
-$name = backup_numbered('a');
+$name = backup_copy_numbered('a');
ok($name, 'a.~2~');
@@ -19,3 +19,3 @@ fileok('a', $name);
mkdir "subdir";
-$name = backup_numbered('a', dir => 'subdir');
+$name = backup_copy_numbered('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a.~1~'));
@@ -24,3 +24,3 @@ fileok('a', $name);
eval {
- backup_numbered('a', dir => 'nonexisting');
+ backup_copy_numbered('a', dir => 'nonexisting');
};
@@ -28,3 +28,3 @@ ok(!!$@);
-$name = backup_numbered('a', dir => 'nonexisting', error => \my $err);
+$name = backup_copy_numbered('a', dir => 'nonexisting', error => \my $err);
ok(!defined($name));
diff --git a/t/02auto.t b/t/02auto.t
index 4717020..0a01d84 100644
--- a/t/02auto.t
+++ b/t/02auto.t
@@ -4,3 +4,3 @@ use strict;
use TestBackup;
-use File::Backup qw(backup_numbered backup_auto);
+use File::BackupCopy qw(backup_copy_numbered backup_copy_auto);
@@ -10,3 +10,3 @@ makefile('a');
-my $name = backup_auto('a');
+my $name = backup_copy_auto('a');
ok($name, 'a~');
@@ -14,3 +14,3 @@ fileok('a', $name);
-$name = backup_numbered('a');
+$name = backup_copy_numbered('a');
ok($name, 'a.~1~');
@@ -18,3 +18,3 @@ fileok('a', $name);
-$name = backup_auto('a');
+$name = backup_copy_auto('a');
ok($name, 'a.~2~');
@@ -23,3 +23,3 @@ fileok('a', $name);
mkdir "subdir";
-$name = backup_auto('a', dir => 'subdir');
+$name = backup_copy_auto('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a~'));
@@ -27,3 +27,3 @@ fileok('a', $name);
-$name = backup_auto('a', dir => 'subdir');
+$name = backup_copy_auto('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a~'));
@@ -32,3 +32,3 @@ fileok('a', $name);
ok(open(FH, '>', File::Spec->catfile('subdir','a.~1~')));
-$name = backup_auto('a', dir => 'subdir');
+$name = backup_copy_auto('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a.~2~'));
@@ -37,3 +37,3 @@ fileok('a', $name);
eval {
- backup_auto('a', dir => 'nonexisting');
+ backup_copy_auto('a', dir => 'nonexisting');
};
@@ -41,3 +41,3 @@ ok(!!$@);
-$name = backup_auto('a', dir => 'nonexisting', error => \my $err);
+$name = backup_copy_auto('a', dir => 'nonexisting', error => \my $err);
ok(!defined($name));
diff --git a/t/03backup.t b/t/03backup.t
index 2b9297d..b040ba7 100644
--- a/t/03backup.t
+++ b/t/03backup.t
@@ -4,3 +4,3 @@ use strict;
use TestBackup;
-use File::Backup;
+use File::BackupCopy;
@@ -10,6 +10,6 @@ makefile('a');
-my $name = backup('a',BACKUP_NONE);
+my $name = backup_copy('a',BACKUP_NONE);
ok(!defined($name));
-$name = backup('a',BACKUP_SIMPLE);
+$name = backup_copy('a',BACKUP_SIMPLE);
ok($name, 'a~');
@@ -17,3 +17,3 @@ fileok('a', $name);
-$name = backup('a',BACKUP_AUTO);
+$name = backup_copy('a',BACKUP_AUTO);
ok($name, 'a~');
@@ -21,3 +21,3 @@ fileok('a', $name);
-$name = backup('a',BACKUP_NUMBERED);
+$name = backup_copy('a',BACKUP_NUMBERED);
ok($name, 'a.~1~');
@@ -25,3 +25,3 @@ fileok('a', $name);
-$name = backup('a',BACKUP_AUTO);
+$name = backup_copy('a',BACKUP_AUTO);
ok($name, 'a.~2~');
@@ -29,3 +29,3 @@ fileok('a', $name);
-$name = backup('a');
+$name = backup_copy('a');
ok($name, 'a.~3~');
@@ -33,3 +33,3 @@ fileok('a', $name);
-$name = backup('a', type => BACKUP_SIMPLE);
+$name = backup_copy('a', type => BACKUP_SIMPLE);
ok($name, 'a~');
@@ -38,3 +38,3 @@ fileok('a', $name);
mkdir "subdir";
-$name = backup('a', dir => 'subdir', type => BACKUP_SIMPLE);
+$name = backup_copy('a', dir => 'subdir', type => BACKUP_SIMPLE);
ok($name, File::Spec->catfile('subdir','a~'));
@@ -42,3 +42,3 @@ fileok('a', $name);
-$name = backup('a', dir => 'subdir', type => BACKUP_AUTO);
+$name = backup_copy('a', dir => 'subdir', type => BACKUP_AUTO);
ok($name, File::Spec->catfile('subdir','a~'));
@@ -46,3 +46,3 @@ fileok('a', $name);
-$name = backup('a', dir => 'subdir', type => BACKUP_NUMBERED);
+$name = backup_copy('a', dir => 'subdir', type => BACKUP_NUMBERED);
ok($name, File::Spec->catfile('subdir','a.~1~'));
@@ -50,3 +50,3 @@ fileok('a', $name);
-$name = backup('a', dir => 'subdir', type => BACKUP_AUTO);
+$name = backup_copy('a', dir => 'subdir', type => BACKUP_AUTO);
ok($name, File::Spec->catfile('subdir','a.~2~'));
@@ -55,3 +55,3 @@ fileok('a', $name);
eval {
- backup('a', dir => 'nonexisting');
+ backup_copy('a', dir => 'nonexisting');
};
@@ -59,3 +59,3 @@ ok(!!$@);
-$name = backup('a', dir => 'nonexisting', error => \my $err);
+$name = backup_copy('a', dir => 'nonexisting', error => \my $err);
ok(!defined($name));
diff --git a/t/04envar.t b/t/04envar.t
index f87f355..f8f1761 100644
--- a/t/04envar.t
+++ b/t/04envar.t
@@ -4,3 +4,3 @@ use strict;
use TestBackup;
-use File::Backup;
+use File::BackupCopy;
@@ -13,3 +13,3 @@ sub test_envar {
$ENV{VERSION_CONTROL} = $val;
- my $name = backup('a');
+ my $name = backup_copy('a');
if (defined($exp)) {

Return to:

Send suggestions and report system problems to the System administrator.