use Sys::Hostname qw(hostname);
use IO::Handle; # ->flush
use Errno qw(EEXIST);
+use File::Path ();
sub new {
my ($class, $dir) = @_;
-
- foreach (qw(new tmp cur)) {
- my $d = "$dir/$_";
- next if -d $d;
- require File::Path;
- if (!File::Path::mkpath($d) && !-d $d) {
- die "failed to mkpath($d): $!\n";
- }
- }
+ File::Path::make_path(map { $dir.$_ } qw(/tmp /new /cur));
bless { dir => $dir, t => 0 }, $class;
}
my ($dir, $head) = @_; # or self
$dir = $dir->{git}->{git_dir} if ref($dir);
require File::Path;
- File::Path::mkpath([ map { "$dir/$_" } qw(objects/info refs/heads) ]);
+ File::Path::make_path(map { $dir.$_ } qw(/objects/info /refs/heads));
$INIT_FILES[1] //= 'ref: '.default_branch."\n";
my @fn_contents = @INIT_FILES;
$fn_contents[1] = "ref: refs/heads/$head\n" if defined $head;
use PublicInbox::Import;
use PublicInbox::ContentHash qw(git_sha);
use Time::HiRes qw(stat); # ctime comparisons for config cache
-use File::Path qw(mkpath);
+use File::Path ();
use File::Spec;
use Sys::Syslog qw(openlog syslog closelog);
our $quit = \&CORE::exit;
return bless {}, 'PublicInbox::Config';
}
my ($cfg_dir) = ($f =~ m!(.*?/)[^/]+\z!);
- -d $cfg_dir or mkpath($cfg_dir) or die "mkpath($cfg_dir): $!\n";
+ File::Path::mkpath($cfg_dir);
open my $fh, '>>', $f or die "open($f): $!\n";
@st = stat($fh) or die "fstat($f): $!\n";
$cur_st = pack('dd', $st[10], $st[7]);
# filter out the epochs we skipped
$self->{chg}->{manifest} = 1 if $m && delete(@$m{@skip});
- (!$self->{dry_run} && !-d $dst) and File::Path::mkpath($dst);
+ $self->{dry_run} or File::Path::mkpath($dst);
$lei->{opt}->{'inbox-config'} =~ /\A(?:always|v2)\z/s and
_get_txt_start($task, '_/text/config/raw', $fini);
sub _pre_augment_maildir {
my ($self, $lei) = @_;
my $dst = $lei->{ovv}->{dst};
- for my $x (qw(tmp new cur)) {
- my $d = $dst.$x;
- next if -d $d;
- require File::Path;
- File::Path::mkpath($d);
- -d $d or die "$d is not a directory";
- }
+ require File::Path;
+ File::Path::make_path(map { $dst.$_ } qw(tmp new cur));
# for utime, so no opendir
open $self->{poke_dh}, '<', "${dst}cur" or die "open ${dst}cur: $!";
}
use File::Temp qw(tempdir);
use DBI qw(:sql_types); # SQL_BLOB
use PublicInbox::Spawn;
-use File::Path qw(rmtree make_path);
+use File::Path qw(rmtree);
sub dbh {
my ($self, $lock) = @_;
sub new {
my ($cls, $dir, $base, $opt) = @_;
my $self = bless { opt => $opt }, $cls;
- make_path($dir) if defined($dir) && !-d $dir;
+ File::Path::mkpath($dir) if defined($dir);
$dir //= $self->{"tmp$$.$self"} = tempdir("skv.$$-XXXX", TMPDIR => 1);
$base //= '';
my $f = $self->{filename} = "$dir/$base.sqlite3";
$lei_opt = { 1 => \$lei_out, 2 => \$lei_err };
my ($daemon_pid, $for_destroy, $daemon_xrd);
my $tmpdir = $test_opt->{tmpdir};
- File::Path::mkpath($tmpdir) if (defined $tmpdir && !-d $tmpdir);
+ File::Path::mkpath($tmpdir) if defined $tmpdir;
($tmpdir, $for_destroy) = tmpdir unless $tmpdir;
state $persist_xrd = $ENV{TEST_LEI_DAEMON_PERSIST_DIR};
SKIP: {
$im->add($patch2) or BAIL_OUT;
};
my $md = "$tmpdir/md";
-File::Path::mkpath([map { $md.$_ } (qw(/ /cur /new /tmp))]);
+File::Path::make_path(map { $md.$_ } (qw(/cur /new /tmp)));
symlink(abs_path('t/solve/0001-simple-mod.patch'), "$md/cur/foo:2,") or
xbail "symlink: $!";
# ensure mbsync and offlineimap compatibility
use strict;
use v5.10.1;
-use File::Path qw(mkpath);
+use File::Path qw(make_path);
use PublicInbox::TestCommon;
use PublicInbox::Spawn qw(spawn);
require_mods(qw(-imapd));
my %pids;
SKIP: {
- mkpath([map { "$tmpdir/oimapdir/$_" } qw(cur new tmp)]);
+ make_path(map { "$tmpdir/oimapdir/$_" } qw(cur new tmp));
my $oimap = require_cmd('offlineimap', 1) or
skip 'no offlineimap(1)', 1;
open my $fh, '>', "$tmpdir/.offlineimaprc" or BAIL_OUT "open: $!";
}
SKIP: {
- mkpath([map { "$tmpdir/mbsyncdir/test/$_" } qw(cur new tmp)]);
+ make_path(map { "$tmpdir/mbsyncdir/test/$_" } qw(cur new tmp));
my $mbsync = require_cmd('mbsync', 1) or skip 'no mbsync(1)', 1;
open my $fh, '>', "$tmpdir/.mbsyncrc" or BAIL_OUT "open: $!";
print $fh <<EOF or BAIL_OUT "print: $!";