OSDN Git Service

New Language: Ada
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-locfil.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                      G N A T . L O C K _ F I L E S                       --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.2 $
10 --                                                                          --
11 --           Copyright (C) 1995-2001 Ada Core Technologies, Inc.            --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- As a special exception,  if other files  instantiate  generics from this --
25 -- unit, or you link  this unit with other files  to produce an executable, --
26 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
27 -- covered  by the  GNU  General  Public  License.  This exception does not --
28 -- however invalidate  any other reasons why  the executable file  might be --
29 -- covered by the  GNU Public License.                                      --
30 --                                                                          --
31 -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).   --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35    --  This package contains the necessary routines for using files for the
36    --  purpose of providing realiable system wide locking capability.
37
38 package GNAT.Lock_Files is
39 pragma Preelaborate;
40
41    Lock_Error : exception;
42    --  Exception raised if file cannot be locked
43
44    procedure Lock_File
45      (Directory      : String;
46       Lock_File_Name : String;
47       Wait           : Duration := 1.0;
48       Retries        : Natural  := Natural'Last);
49    --  Create a lock file Lock_File_Name in directory Directory. If the file
50    --  cannot be locked because someone already owns the lock, this procedure
51    --  waits Wait seconds and retries at most Retries times. If the file
52    --  still cannot be locked, Lock_Error is raised. The default is to try
53    --  every second, almost forever (Natural'Last times).
54
55    procedure Lock_File
56      (Lock_File_Name : String;
57       Wait           : Duration := 1.0;
58       Retries        : Natural  := Natural'Last);
59    --  See above. The full lock file path is given as one string.
60
61    procedure Unlock_File (Directory : String; Lock_File_Name : String);
62    --  Unlock a file
63
64    procedure Unlock_File (Lock_File_Name : String);
65    --  Unlock a file whose full path is given in Lock_File_Name
66
67 end GNAT.Lock_Files;