- We don't use the FILEHANDLE,MODE,FILENAME version of open() any more, because it doesn't work everywhere
- add_file() and remove_file() now return true if they succeed
- unlock() doesn't check any more if the lock file already exists
#
# Run a list with files that are currently in use
# (bases on Filing::UseList by Roland Bluethgen <calocybe@web.de>)
#
# Author: Patrick Canterino <patshaping@gmx.net>
#
# Run a list with files that are currently in use
# (bases on Filing::UseList by Roland Bluethgen <calocybe@web.de>)
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2003-10-17
+# Last modified: 2003-11-21
- unless(-f $lockfile)
- {
- open(LOCKFILE,">",$lockfile) or return;
- close(LOCKFILE) or return;
- }
+ open(LOCKFILE,">$lockfile") or return;
+ close(LOCKFILE) or return;
$self->{'locked'} = 0;
return 1;
$self->{'locked'} = 0;
return 1;
# 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);
read(FILE, my $content, -s $file);
my @files = split(/\015\012|\012|\015/,$content);
my @files = split(/\015\012|\012|\015/,$content);
my $data = (@$files) ? join("\n",@$files) : '';
my $data = (@$files) ? join("\n",@$files) : '';
- open(FILE,">",$temp) or return;
- print FILE $data or do { close(FILE); return };
- close(FILE) or return;
+ open(FILE,">$temp") or return;
+ print FILE $data or do { close(FILE); return };
+ close(FILE) or return;
- rename($temp,$file) or return;
+ rename($temp,$file) or return;
# Add a file to the list
#
# Params: File
# Add a file to the list
#
# Params: File
+#
+# Return: Status code (Boolean)
return if($self->in_use($file));
push(@$files,$file);
return if($self->in_use($file));
push(@$files,$file);
# Remove a file from the list
#
# Params: File
# Remove a file from the list
#
# Params: File
+#
+# Return: Status code (Boolean)
if($files->[$x] eq $file)
{
splice(@$files,$x,1);
if($files->[$x] eq $file)
{
splice(@$files,$x,1);