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