PR target/60039
[official-gcc.git] / gcc / ada / g-locfil.ads
blobb8213cdb0d82e98958fbda76903ce0b89bf41ff7
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-2010, AdaCore --
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 3, 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. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 -- This package contains the necessary routines for using files for the
33 -- purpose of providing reliable system wide locking capability.
35 package GNAT.Lock_Files is
36 pragma Preelaborate;
38 Lock_Error : exception;
39 -- Exception raised if file cannot be locked
41 subtype Path_Name is String;
42 -- Pathname is used by all services provided in this unit to specified
43 -- directory name and file name. On DOS based systems both directory
44 -- separators are handled (i.e. slash and backslash).
46 procedure Lock_File
47 (Directory : Path_Name;
48 Lock_File_Name : Path_Name;
49 Wait : Duration := 1.0;
50 Retries : Natural := Natural'Last);
51 -- Create a lock file Lock_File_Name in directory Directory. If the file
52 -- cannot be locked because someone already owns the lock, this procedure
53 -- waits Wait seconds and retries at most Retries times. If the file
54 -- still cannot be locked, Lock_Error is raised. The default is to try
55 -- every second, almost forever (Natural'Last times). The full path of
56 -- the file is constructed by concatenating Directory and Lock_File_Name.
57 -- Directory can optionally terminate with a directory separator.
59 procedure Lock_File
60 (Lock_File_Name : Path_Name;
61 Wait : Duration := 1.0;
62 Retries : Natural := Natural'Last);
63 -- See above. The full lock file path is given as one string
65 procedure Unlock_File (Directory : Path_Name; Lock_File_Name : Path_Name);
66 -- Unlock a file. Directory can optionally terminate with a directory
67 -- separator.
69 procedure Unlock_File (Lock_File_Name : Path_Name);
70 -- Unlock a file whose full path is given in Lock_File_Name
72 end GNAT.Lock_Files;