<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#webliberty::Lock.pm (2006/02/18)
#Copyright(C) 2002-2006 Knight, All rights reserved.

package webliberty::Lock;

use strict;

### ã‚³ãƒ³ã‚¹ãƒˆãƒ©ã‚¯ã‚¿
sub new {
	my $class = shift;

	my $self = {
		file =&gt; shift
	};
	bless $self, $class;

	return $self;
}

### ãƒ­ãƒƒã‚¯ä½œæˆ
sub file_lock {
	my $self = shift;

	my $flag;

	foreach (1 .. 5) {
		if (-e $self-&gt;{file}) {
			if (time &gt; (stat($self-&gt;{file}))[9] + 10) {
				$self-&gt;file_unlock($self-&gt;{file});
				next;
			}
			sleep(1);
		} else {
			if (open(FH, "&gt;$self-&gt;{file}")) {
				close(FH);
				$flag = 1;
			}
			last;
		}
	}

	return $flag;
}

### ãƒ­ãƒƒã‚¯è§£é™¤
sub file_unlock {
	my $self = shift;

	unlink($self-&gt;{file});

	return;
}

1;
</pre></body></html>