Need File locking Help for Windows.

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
bro_co03
-


Joined: 08 Sep 2003
Posts: 12
Location: Lone Star State

PostPosted: Sat Dec 18, 2004 5:12 am    Post subject: Need File locking Help for Windows. Reply with quote

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");

_________________
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group