Changeset 28066 for main/trunk/greenstone2/perllib/util.pm
- Timestamp:
- 2013-08-15T16:42:23+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/util.pm
r27970 r28066 226 226 } 227 227 228 # These 2 are "static" variables used by the get_timestamped_tmp_folder() subroutine below and 229 # belong with that function. They help ensure the timestamped tmp folders generated are unique. 230 my $previous_timestamp = undef; 231 my $previous_timestamp_f = 0; # frequency 232 228 233 sub get_timestamped_tmp_folder 229 234 { 230 235 231 236 my $tmp_dirname; 232 237 if(defined $ENV{'GSDLCOLLECTDIR'}) { … … 243 248 # add the timestamp into the path otherwise we can run into problems 244 249 # if documents have the same name 245 my $timestamp = time; 250 my $timestamp = time; 251 252 if (!defined $previous_timestamp || ($timestamp > $previous_timestamp)) { 253 $previous_timestamp_f = 0; 254 $previous_timestamp = $timestamp; 255 } else { 256 $previous_timestamp_f++; 257 } 258 246 259 my $time_tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, $timestamp); 247 $tmp_dirname = $time_tmp_dirname; 248 my $i = 1; 260 $tmp_dirname = $time_tmp_dirname; 261 my $i = $previous_timestamp_f; 262 263 if($previous_timestamp_f > 0) { 264 $tmp_dirname = $time_tmp_dirname."_".$i; 265 $i++; 266 } 249 267 while (-e $tmp_dirname) { 250 $tmp_dirname = "$time_tmp_dirname$i";268 $tmp_dirname = $time_tmp_dirname."_".$i; 251 269 $i++; 252 270 } 253 &FileUtils::makeDirectory($tmp_dirname); 254 271 &FileUtils::makeDirectory($tmp_dirname); 272 255 273 return $tmp_dirname; 256 274 }
Note:
See TracChangeset
for help on using the changeset viewer.