bro_co03 -
Joined: 08 Sep 2003 Posts: 12 Location: Lone Star State
|
Posted: Sat Dec 18, 2004 5:12 am Post subject: Need File locking Help for Windows. |
|
|
I know file locking doesn't work on windows, but I think I found away around it...
Will this code help protect my files?
Code: | # Locks File for Windows ME
$check_var = 0;
while ($check_var=0) {
if (-e "./lock/testfile.lock") { $check_var = 1; }
else { $check_var = 0; }
}
# Create "Lock" File
open(TEMPORARYLOCK,">>./lock/testfile.lock");
print TEMPORARYLOCK "testfile.txt is in use";
close(TEMPORARYLOCK);
# Open the File
open(TESTFILE,"./testdir/testfile.txt");
@testarray = <TESTFILE>;
close(TESTFILE);
# Remove the "Lock" File
unlink("./lock/testfile.lock"); |
_________________
|
|