summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
258ec0b)
- Improved constructor
- If we tried to unlock the list file and the lock file already exists, the 'lock' variable in the object properties wasn't set to 0
- Fixed a lot of typos
- Removed $VERSION variable (version number is now found in the head comment)
#
# Run a list with files that are currently in use
#
# Run a list with files that are currently in use
-# (bases upon Filing::UseList by Roland Bluethgen <calocybe@web.de>)
+# (bases on Filing::UseList by Roland Bluethgen <calocybe@web.de>)
#
# Author: Patrick Canterino <patshaping@gmx.net>
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 09-26-2003
+# Last modified: 2003-10-17
#
use strict;
use Carp qw(croak);
#
use strict;
use Carp qw(croak);
# lockfile => Lock file (Default: List file + .lock)
# timeout => Lock timeout in seconds (Default: 10)
#
# lockfile => Lock file (Default: List file + .lock)
# timeout => Lock timeout in seconds (Default: 10)
#
-# Return: File::UseList object
+# Return: File::UseList object (Blessed Reference)
# Check if we got all the necessary information
# Check if we got all the necessary information
- croak "Missing path of list file" unless($args{'listfile'});
- $args{'lockfile'} = $args{'listfile'}.".lock" unless($args{'lockfile'}); # Default filename of lock file
- $args{'timeout'} = 10 unless($args{'timeout'}); # Default timeout
+ croak "Missing path to list file" unless($args{'listfile'});
+ $args{'lockfile'} = $args{'listfile'}.".lock" unless($args{'lockfile'}); # Default filename of lock file
+ $args{'timeout'} = 10 unless($args{'timeout'}); # Default timeout
+ # Add some other information
- my $self = \%args;
- $self->{'files'} = [];
- $self->{'locked'} = 0;
+ $args{'files'} = [];
+ $args{'locked'} = 0;
- return bless($self,$class);
+ return bless(\%args,$class);
- return 1 if(-f $lockfile); # Hmmm...
-
- open(LOCKFILE,">",$lockfile) or return;
- close(LOCKFILE) or return;
+ unless(-f $lockfile)
+ {
+ open(LOCKFILE,">",$lockfile) or return;
+ close(LOCKFILE) or return;
+ }
- # The list wasn't lock by ourselves
+ # The list wasn't lock by us or it isn't locked at all
-# Load the list with files
+# Load the list with files from the list file
# Read out the file and split the content line-per-line
# Read out the file and split the content line-per-line
- open(FILE,"<".$file) or return;
+ open(FILE,"<",$file) or return;
read(FILE, my $content, -s $file);
close(FILE) or return;
read(FILE, my $content, -s $file);
close(FILE) or return;
-# Save the list with files
+# Write the list with files back to the list file
print FILE $data or do { close(FILE); return };
close(FILE) or return;
print FILE $data or do { close(FILE); return };
close(FILE) or return;
- rename($temp,$file) and return 1;
-
- # Rubbish
+ rename($temp,$file) or return;
-### Ende ###
\ No newline at end of file
+### End ###
\ No newline at end of file