From 11de71b3465be077761a9003dad2a8bdd646d992 Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Fri, 3 Dec 2004 14:04:28 +0000 Subject: [PATCH] Version 1.3: - Replaced open() by sysopen() - Added method remove_all() to remove all files from the list (maybe we will need it...) - Changed my email address --- modules/File/UseList.pm | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/modules/File/UseList.pm b/modules/File/UseList.pm index 6f7ff62..29db298 100644 --- a/modules/File/UseList.pm +++ b/modules/File/UseList.pm @@ -1,18 +1,19 @@ package File::UseList; # -# File::UseList 1.2 +# File::UseList 1.3 # # Run a list with files that are currently in use # (bases on Filing::UseList by Roland Bluethgen ) # -# Author: Patrick Canterino -# Last modified: 2003-11-21 +# Author: Patrick Canterino +# Last modified: 2004-12-03 # use strict; use Carp qw(croak); +use Fcntl; # new() # @@ -95,8 +96,8 @@ sub unlock if($self->{'locked'}) { - open(LOCKFILE,">$lockfile") or return; - close(LOCKFILE) or return; + sysopen(LOCKFILE,$lockfile,O_WRONLY | O_CREAT | O_TRUNC) or return; + close(LOCKFILE) or return; $self->{'locked'} = 0; return 1; @@ -123,9 +124,9 @@ sub load # Read out the file and split the content line-per-line - open(FILE,"<$file") or return; + sysopen(FILE,$file,O_RDONLY) or return; read(FILE, my $content, -s $file); - close(FILE) or return; + close(FILE) or return; my @files = split(/\015\012|\012|\015/,$content); @@ -162,11 +163,11 @@ sub save my $data = (@$files) ? join("\n",@$files) : ''; - open(FILE,">$temp") or return; - print FILE $data or do { close(FILE); return }; - close(FILE) or return; + sysopen(FILE,$temp,O_WRONLY | O_CREAT | O_TRUNC) or return; + print FILE $data or do { close(FILE); return }; + close(FILE) or return; - rename($temp,$file) or return; + rename($temp,$file) or return; return 1; } @@ -221,6 +222,23 @@ sub remove_file($) } } +# remove_all() +# +# Remove all files from the list +# +# Params: -nothing- +# +# Return: -nothing- + +sub remove_all +{ + my $self = shift; + + $self->{'files'} = []; + + return; +} + # in_use() # # Check if a file is in the list -- 2.34.1