@@ -61,7 +61,7 @@ require Exporter;
6161 remote_refs prompt
6262 get_tz_offset
6363 credential credential_read credential_write
64- temp_acquire temp_release temp_reset temp_path) ;
64+ temp_acquire temp_is_locked temp_release temp_reset temp_path) ;
6565
6666
6767=head1 DESCRIPTION
@@ -1206,6 +1206,35 @@ sub temp_acquire {
12061206 $temp_fd ;
12071207}
12081208
1209+ =item temp_is_locked ( NAME )
1210+
1211+ Returns true if the internal lock created by a previous C<temp_acquire() >
1212+ call with C<NAME > is still in effect.
1213+
1214+ When temp_acquire is called on a C<NAME > , it internally locks the temporary
1215+ file mapped to C<NAME > . That lock will not be released until C<temp_release() >
1216+ is called with either the original C<NAME > or the L<File::Handle> that was
1217+ returned from the original call to temp_acquire.
1218+
1219+ Subsequent attempts to call C<temp_acquire() > with the same C<NAME > will fail
1220+ unless there has been an intervening C<temp_release() > call for that C<NAME >
1221+ (or its corresponding L<File::Handle> that was returned by the original
1222+ C<temp_acquire() > call).
1223+
1224+ If true is returned by C<temp_is_locked() > for a C<NAME > , an attempt to
1225+ C<temp_acquire() > the same C<NAME > will cause an error unless
1226+ C<temp_release > is first called on that C<NAME > (or its corresponding
1227+ L<File::Handle> that was returned by the original C<temp_acquire() > call).
1228+
1229+ =cut
1230+
1231+ sub temp_is_locked {
1232+ my ($self , $name ) = _maybe_self(@_ );
1233+ my $temp_fd = \$TEMP_FILEMAP {$name };
1234+
1235+ defined $$temp_fd && $$temp_fd -> opened && $TEMP_FILES {$$temp_fd }{locked };
1236+ }
1237+
12091238=item temp_release ( NAME )
12101239
12111240=item temp_release ( FILEHANDLE )
0 commit comments