OSDN Git Service

* 1aexcept.adb, 1aexcept.ads, 1ic.ads, 1ssecsta.adb,
[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 --           Copyright (C) 1995-2001 Ada Core Technologies, Inc.            --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).   --
30 --                                                                          --
31 ------------------------------------------------------------------------------
32
33 --  This package contains the necessary routines for using files for the
34 --  purpose of providing realiable system wide locking capability.
35
36 package GNAT.Lock_Files is
37 pragma Preelaborate;
38
39    Lock_Error : exception;
40    --  Exception raised if file cannot be locked
41
42    subtype Path_Name is String;
43    --  Pathname is used by all services provided in this unit to specified
44    --  directory name and file name. On DOS based systems both directory
45    --  separators are handled (i.e. slash and backslash).
46
47    procedure Lock_File
48      (Directory      : Path_Name;
49       Lock_File_Name : Path_Name;
50       Wait           : Duration := 1.0;
51       Retries        : Natural  := Natural'Last);
52    --  Create a lock file Lock_File_Name in directory Directory. If the file
53    --  cannot be locked because someone already owns the lock, this procedure
54    --  waits Wait seconds and retries at most Retries times. If the file
55    --  still cannot be locked, Lock_Error is raised. The default is to try
56    --  every second, almost forever (Natural'Last times). The full path of
57    --  the file is constructed by concatenating Directory and Lock_File_Name.
58    --  Directory can optionally terminate with a directory separator.
59
60    procedure Lock_File
61      (Lock_File_Name : Path_Name;
62       Wait           : Duration := 1.0;
63       Retries        : Natural  := Natural'Last);
64    --  See above. The full lock file path is given as one string.
65
66    procedure Unlock_File (Directory : Path_Name; Lock_File_Name : Path_Name);
67    --  Unlock a file. Directory can optionally terminate with a directory
68    --  separator.
69
70    procedure Unlock_File (Lock_File_Name : Path_Name);
71    --  Unlock a file whose full path is given in Lock_File_Name
72
73 end GNAT.Lock_Files;