Changeset 27682
- Timestamp:
- 2013-06-21T12:19:57+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/parallel-building/trunk/src/perllib/FileUtils/LocalFS.pm
r27638 r27682 240 240 } 241 241 # /** linkFile() **/ 242 243 244 ## @function makeAllDirectories() 245 # 246 # in case anyone cares - I did some testing (using perls Benchmark module) 247 # on this subroutine against File::Path::mkpath (). mk_all_dir() is apparently 248 # slightly faster (surprisingly) - Stefan. 249 # 250 sub makeAllDirectories 251 { 252 my ($dir) = @_; 253 254 # use / for the directory separator, remove duplicate and 255 # trailing slashes 256 $dir=~s/[\\\/]+/\//g; 257 $dir=~s/[\\\/]+$//; 258 259 # make sure the cache directory exists 260 my $dirsofar = ""; 261 my $first = 1; 262 foreach my $dirname (split ("/", $dir)) 263 { 264 $dirsofar .= "/" unless $first; 265 $first = 0; 266 267 $dirsofar .= $dirname; 268 269 next if $dirname =~ /^(|[a-z]:)$/i; 270 if (!-e $dirsofar) 271 { 272 my $store_umask = umask(0002); 273 my $mkdir_ok = mkdir ($dirsofar, 0777); 274 umask($store_umask); 275 if (!$mkdir_ok) 276 { 277 print STDERR "FileUtils::makeAllDirectories() could not create directory $dirsofar\n"; 278 return; 279 } 280 } 281 } 282 return 1; 283 } 284 ## makeAllDirectories() 285 242 286 243 287 ## @function makeDirectory()
Note:
See TracChangeset
for help on using the changeset viewer.