text stringlengths 0 834k |
|---|
my $dir = $tmpdir . $name; |
next if -d $dir; |
mkdir $dir or die ""Cannot mkdir $dir: $!\n""; |
$prefix_dir = $dir; |
last; |
} |
if (!defined $prefix_dir) { |
die ""failed to derive a random temp directory name after $N "", |
""attempts\n""; |
} |
} |
} |
#warn ""prefix dir: $prefix_dir\n""; |
my $child_pid; |
END { |
if (!$is_win32 && defined($child_pid) && defined $prefix_dir) { |
my $saved_status = $?; |
system(""rm -rf $prefix_dir"") == 0 |
or warn ""failed to remove temp directory $prefix_dir: $!""; |
$? = $saved_status; # restore the exit code |
} |
} |
my $logs_dir; |
if ($is_win32) { |
$logs_dir = File::Spec->catfile($prefix_dir, ""logs""); |
} else { |
$logs_dir = ""$prefix_dir/logs""; |
} |
mkdir $logs_dir or die ""failed to mkdir $logs_dir: $!""; |
my $conf_dir; |
if ($is_win32) { |
$conf_dir = File::Spec->catfile($prefix_dir, ""conf""); |
} else { |
$conf_dir = ""$prefix_dir/conf""; |
} |
mkdir $conf_dir or die ""failed to mkdir $conf_dir: $!""; |
my $inline_lua = ''; |
my $quoted_luafile; |
if (defined $src) { |
my $file; |
if ($is_win32) { |
$file = File::Spec->catfile($conf_dir, ""a.lua""); |
} else { |
$file = ""$conf_dir/a.lua""; |
} |
open my $out, "">$file"" |
or die ""Cannot open $file for writing: $!\n""; |
print $out $src; |
close $out; |
my $chunk_name = ""=(command line -e)""; |
$quoted_luafile = quote_as_lua_str($file); |
$inline_lua = <<""_EOC_""; |
local fname = $quoted_luafile |
local f = assert(io.open(fname, ""r"")) |
local chunk = f:read(""*a"") |
local inline_gen = assert(loadstring(chunk, ""$chunk_name"")) |
_EOC_ |
} |
my $file_lua = ''; |
if (defined $luafile) { |
if (!-e $luafile) { |
die ""Lua input file $luafile not found.\n""; |
} |
my $chunk_name = quote_as_lua_str(""\@$luafile""); |
$quoted_luafile = quote_as_lua_str($luafile); |
$file_lua = <<""_EOC_""; |
local fname = $quoted_luafile |
local f = assert(io.open(fname, ""r"")) |
local chunk = f:read(""*a"") |
local file_gen = assert(loadstring(chunk, $chunk_name)) |
_EOC_ |
} |
my @user_args = @ARGV; |
my $args = gen_lua_code_for_args(\@user_args, \@all_args); |
my $loader = <<_EOC_; |
local gen |
do |
$args |
$inline_lua |
$file_lua |
gen = function() |
if inline_gen then inline_gen() end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.