?revision_form?Rev ?revision_input??revision_submit??revision_endform?
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package DebPool
::Util;
###
#
# DebPool::Util - Module to contain various utility routines
#
# Copyright 2004 Joel Aelwyn. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the Author nor the names of any contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Id: Util.pm 27 2004-11-07 03:06:59Z joel $
#
###
# We use 'our', so we must have at least Perl 5.6
require 5.006_000
;
# Always good ideas.
use strict
;
use warnings
;
use File
::Copy;
### Module setup
BEGIN {
use Exporter
();
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
# Version checking
$VERSION = '0.1.5';
@ISA = qw(Exporter
);
@EXPORT = qw(
);
@EXPORT_OK = qw(
&Move_File
);
%EXPORT_TAGS = (
'functions' => [qw(&Move_File)],
'vars' => [qw()],
);
}
### Exported package globals
# None
### Non-exported package globals
# Thread-safe? What's that? Package global error value. We don't export
# this directly, because it would conflict with other modules.
our($Error);
### File lexicals
# None
### Constant functions
# None
### Meaningful functions
# Move_File($orig, $new, $mode)
#
# Move an file from $orig to $new by copying, and set the file mode
# of the new file according to the variables given.
#
# Returns 1 if successful, 0 if not (and sets $Error)
sub Move_File
{
my($orig) = shift(@_);
my($new) = shift(@_);
my($mode) = shift(@_);
if (!copy
($orig, $new)) {
$Error = $!;
return 0;
}
if (!chmod($mode, $new)) {
$Error = $!;
return 0;
}
if (!unlink($orig)) {
$Error = $!;
return 0;
}
return 1;
}
END
{}
1;
__END__
# vim:set tabstop=4 expandtab: