#!/usr/local/bin/perl -w
ok(1);
my
$template
= File::Spec->catfile(File::Temp::_wrap_file_spec_tmpdir(),
'wowserXXXX'
);
(
my
$fh
,
$template
) = mkstemp(
$template
);
print
"# MKSTEMP: FH is $fh File is $template fileno="
.
fileno
(
$fh
).
"\n"
;
ok( (-e
$template
) );
$fh
->autoflush(1)
if
$] >= 5.006;
my
$string
=
"woohoo\n"
;
print
$fh
$string
;
ok(
seek
(
$fh
, 0, 0));
my
$line
= <
$fh
>;
ok(
$string
,
$line
);
if
($^O eq
'MSWin32'
) {
sleep
3;
}
my
$status
= unlink0(
$fh
,
$template
);
if
(
$status
) {
ok(
$status
);
}
else
{
SKIP: {
skip(
"Skip test failed probably due to \$TMPDIR being on NFS"
,1);
}
}
$template
=
"suffixXXXXXX"
;
my
$suffix
=
".dat"
;
(
$fh
,
my
$fname
) = mkstemps(
$template
,
$suffix
);
print
"# MKSTEMPS: File is $template -> $fname fileno="
.
fileno
(
$fh
).
"\n"
;
ok( (-e
$fname
) );
$status
= unlink0(
$fh
,
$fname
);
if
(
$status
) {
ok(
$status
);
}
else
{
SKIP: {
skip(
"Skip test failed probably due to cwd being on NFS"
,1)
}
}
$template
= File::Spec->catdir(File::Temp::_wrap_file_spec_tmpdir(),
'tmpdirXXXXXX'
);
my
$tmpdir
= mkdtemp(
$template
);
print
"# MKDTEMP: Name is $tmpdir from template $template\n"
;
ok( (-d
$tmpdir
) );
rmtree(
$tmpdir
);
$template
= File::Spec->catfile(File::Temp::_wrap_file_spec_tmpdir(),
'mytestXXXXXX'
);
my
$tmpfile
= mktemp(
$template
);
print
"# MKTEMP: Tempfile is $template -> $tmpfile\n"
;
ok( (
$tmpfile
!~ /XXXXX$/) );