Initial commit
[clearscm.git] / maps / bin / MAPSFile.pm
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         $RCSfile: MAPSFile.pm,v $
5 # Revision:     $Revision: 1.1 $
6 # Description:  File manipulation routines for MAPS.
7 # Author:       Andrew@DeFaria.com
8 # Created:      Fri Nov 29 14:17:21  2002
9 # Modified:     $Date: 2013/06/12 14:05:47 $
10 # Language:     perl
11 #
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
13 #
14 ################################################################################
15 package MAPSFile;
16
17 use strict;
18 use vars qw (@ISA @EXPORT);
19
20 use Fcntl ':flock'; # import LOCK_* constants
21
22 use Exporter;
23 @ISA = qw (Exporter);
24
25 @EXPORT = qw (
26   Lock
27   Unlock
28 );
29
30 sub Lock {
31   my $file = shift;
32
33   flock ($file, LOCK_EX);
34   # and, in case someone appended while we were waiting...
35   seek ($file, 0, 2);
36 } # lock
37
38 sub Unlock {
39   my $file = shift;
40   flock ($file,LOCK_UN);
41 } # unlock
42
43 1;