summaryrefslogtreecommitdiff
path: root/gcc/ada/a-direct.ads
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-05 14:57:42 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-05 14:57:42 +0000
commitd24d7e81b6a309d113bc69412592c363733bc095 (patch)
tree2d91f19f11f8b38d7d3f5b5cf90649006ce6ddb8 /gcc/ada/a-direct.ads
parent66d12a6c0042f50195e3775da6684f7455019f15 (diff)
downloadgcc-d24d7e81b6a309d113bc69412592c363733bc095.tar.gz
2004-04-05 Vincent Celier <celier@gnat.com>
* adaint.h, adaint.c: Add function __gnat_named_file_length * impunit.adb: Add Ada.Directories to the list * Makefile.in: Add VMS and Windows versions of Ada.Directories.Validity package body. * Makefile.rtl: Add a-direct and a-dirval * mlib-tgt.ads: Minor comment update. * a-dirval.ads, a-dirval.adb, 5vdirval.adb, 5wdirval.adb, a-direct.ads, a-direct.adb: New files. 2004-04-05 Vincent Celier <celier@gnat.com> PR ada/13620 * make.adb (Scan_Make_Arg): Pass any -fxxx switches to gnatlink, not just to the compiler. 2004-04-05 Robert Dewar <dewar@gnat.com> * a-except.adb (Exception_Name_Simple): Make sure lower bound of returned string is 1. * ali-util.adb: Use proper specific form for Warnings (Off, entity) * eval_fat.ads: Minor reformatting * g-curexc.ads: Document that lower bound of returned string values is always one. * gnatlink.adb: Add ??? comment for previous change (need to document why this is VMS specific) * s-stoele.ads: Minor reformatting * tbuild.ads: Minor reformatting throughout (new function specs) * par-ch10.adb (P_Context_Clause): Handle comma instead of semicolon after WITH. * scng.adb: Minor reformatting 2004-04-05 Geert Bosch <bosch@gnat.com> * eval_fat.adb (Machine): Remove unnecessary suppression of warning. (Leading_Part): Still perform truncation to machine number if the specified radix_digits is greater or equal to machine_mantissa. 2004-04-05 Javier Miranda <miranda@gnat.com> * par-ch3.adb: Complete documentation of previous change Correct wrong syntax documentation of the OBJECT_DECLARATION rule (aliased must appear before constant). * par-ch4.adb: Complete documentation of previous change. * par-ch6.adb: Complete documentation of previous change. * sinfo.ads: Fix typo in commment. 2004-04-05 Ed Schonberg <schonberg@gnat.com> * sem_ch3.adb (Inherit_Components): If derived type is private and has stored discriminants, use its discriminants to constrain parent type, as is done for non-private derived record types. * sem_ch4.adb (Remove_Abstract_Operations): New subprogram to implement Ada 2005 AI-310: an abstract non-dispatching operation is not a candidate interpretation in an overloaded call. * tbuild.adb (Unchecked_Convert_To): Preserve conversion node if expression is Null and target type is not an access type (e.g. a non-private address type). 2004-04-05 Thomas Quinot <quinot@act-europe.fr> * exp_ch6.adb (Rewrite_Function_Call): When rewriting an assignment statement whose right-hand side is an inlined call, save a copy of the original assignment subtree to preserve enough consistency for Analyze_Assignment to proceed. * sem_ch5.adb (Analyze_Assignment): Remove a costly copy of the complete assignment subtree which is now unnecessary, as the expansion of inlined call has been improved to preserve a consistent assignment tree. Note_Possible_Modification must be called only after checks have been applied, or else unnecessary checks will be generated. * sem_util.adb (Note_Possible_Modification): Reorganise the handling of explicit dereferences that do not Come_From_Source: - be selective on cases where we must go back to the dereferenced pointer (an assignment to an implicit dereference must not be recorded as modifying the pointer); - do not rely on Original_Node being present (Analyze_Assignment calls Note_Possible_Modification on a copied tree). * sem_warn.adb (Check_References): When an unset reference to a pointer that is never assigned is encountered, prefer '<pointer> may be null' warning over '<pointer> is never assigned a value'. 2004-04-05 Ramon Fernandez <fernandez@gnat.com> * tracebak.c: Change STOP_FRAME in ppc vxworks to be compliant with the ABI. 2004-04-05 Olivier Hainque <hainque@act-europe.fr> * 5gmastop.adb (Pop_Frame): Comment out the pragma Linker_Option for libexc. We currently don't reference anything in this library and linking it in triggers linker warnings we don't want to see. * init.c: Update comments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80431 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-direct.ads')
-rw-r--r--gcc/ada/a-direct.ads415
1 files changed, 415 insertions, 0 deletions
diff --git a/gcc/ada/a-direct.ads b/gcc/ada/a-direct.ads
new file mode 100644
index 00000000000..b5ed79b3bee
--- /dev/null
+++ b/gcc/ada/a-direct.ads
@@ -0,0 +1,415 @@
+------------------------------------------------------------------------------
+-- --
+-- GNAT RUN-TIME COMPONENTS --
+-- --
+-- A D A . D I R E C T O R I E S --
+-- --
+-- S p e c --
+-- --
+-- Copyright (C) 2004 Free Software Foundation, Inc. --
+-- --
+-- This specification is derived for use with GNAT from AI-00248, which is --
+-- expected to be a part of a future expected revised Ada Reference Manual. --
+-- The copyright notice above, and the license provisions that follow apply --
+-- solely to the contents of the part following the private keyword. --
+-- --
+-- GNAT is free software; you can redistribute it and/or modify it under --
+-- terms of the GNU General Public License as published by the Free Soft- --
+-- ware Foundation; either version 2, or (at your option) any later ver- --
+-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
+-- for more details. You should have received a copy of the GNU General --
+-- Public License distributed with GNAT; see file COPYING. If not, write --
+-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
+-- MA 02111-1307, USA. --
+-- --
+-- As a special exception, if other files instantiate generics from this --
+-- unit, or you link this unit with other files to produce an executable, --
+-- this unit does not by itself cause the resulting executable to be --
+-- covered by the GNU General Public License. This exception does not --
+-- however invalidate any other reasons why the executable file might be --
+-- covered by the GNU Public License. --
+-- --
+-- GNAT was originally developed by the GNAT team at New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc. --
+-- --
+------------------------------------------------------------------------------
+
+-- Ada0Y: Implementation of Ada.Directories (AI95-00248). Note that this
+-- unit is available without -gnatX. That seems reasonable, since you only
+-- get it if you explicitly ask for it.
+
+-- External files may be classified as directories, special files, or ordinary
+-- files. A directory is an external file that is a container for files on
+-- the target system. A special file is an external file that cannot be
+-- created or read by a predefined Ada Input-Output package. External files
+-- that are not special files or directories are called ordinary files.
+
+-- A file name is a string identifying an external file. Similarly, a
+-- directory name is a string identifying a directory. The interpretation of
+-- file names and directory names is implementation-defined.
+
+-- The full name of an external file is a full specification of the name of
+-- the file. If the external environment allows alternative specifications of
+-- the name (for example, abbreviations), the full name should not use such
+-- alternatives. A full name typically will include the names of all of
+-- directories that contain the item. The simple name of an external file is
+-- the name of the item, not including any containing directory names. Unless
+-- otherwise specified, a file name or directory name parameter to a
+-- predefined Ada input-output subprogram can be a full name, a simple name,
+-- or any other form of name supported by the implementation.
+
+-- The default directory is the directory that is used if a directory or
+-- file name is not a full name (that is, when the name does not fully
+-- identify all of the containing directories).
+
+-- A directory entry is a single item in a directory, identifying a single
+-- external file (including directories and special files).
+
+-- For each function that returns a string, the lower bound of the returned
+-- value is 1.
+
+with Ada.Calendar;
+with Ada.Finalization;
+with Ada.IO_Exceptions;
+with Ada.Strings.Unbounded;
+
+package Ada.Directories is
+
+ -----------------------------------
+ -- Directory and File Operations --
+ -----------------------------------
+
+ function Current_Directory return String;
+ -- Returns the full directory name for the current default directory. The
+ -- name returned shall be suitable for a future call to Set_Directory.
+ -- The exception Use_Error is propagated if a default directory is not
+ -- supported by the external environment.
+
+ procedure Set_Directory (Directory : String);
+ -- Sets the current default directory. The exception Name_Error is
+ -- propagated if the string given as Directory does not identify an
+ -- existing directory. The exception Use_Error is propagated if the
+ -- external environment does not support making Directory (in the absence
+ -- of Name_Error) a default directory.
+
+ procedure Create_Directory
+ (New_Directory : String;
+ Form : String := "");
+ -- Creates a directory with name New_Directory. The Form parameter can be
+ -- used to give system-dependent characteristics of the directory; the
+ -- interpretation of the Form parameter is implementation-defined. A null
+ -- string for Form specifies the use of the default options of the
+ -- implementation of the new directory. The exception Name_Error is
+ -- propagated if the string given as New_Directory does not allow the
+ -- identification of a directory. The exception Use_Error is propagated if
+ -- the external environment does not support the creation of a directory
+ -- with the given name (in the absence of Name_Error) and form.
+
+ procedure Delete_Directory (Directory : String);
+ -- Deletes an existing empty directory with name Directory. The exception
+ -- Name_Error is propagated if the string given as Directory does not
+ -- identify an existing directory. The exception Use_Error is propagated
+ -- if the external environment does not support the deletion of the
+ -- directory (or some portion of its contents) with the given name (in the
+ -- absence of Name_Error).
+
+ procedure Create_Path
+ (New_Directory : String;
+ Form : String := "");
+ -- Creates zero or more directories with name New_Directory. Each
+ -- non-existent directory named by New_Directory is created. For example,
+ -- on a typical Unix system, Create_Path ("/usr/me/my"); would create
+ -- directory "me" in directory "usr", then create directory "my" in
+ -- directory "me". The Form can be used to give system-dependent
+ -- characteristics of the directory; the interpretation of the Form
+ -- parameter is implementation-defined. A null string for Form specifies
+ -- the use of the default options of the implementation of the new
+ -- directory. The exception Name_Error is propagated if the string given
+ -- as New_Directory does not allow the identification of any directory.
+ -- The exception Use_Error is propagated if the external environment does
+ -- not support the creation of any directories with the given name (in the
+ -- absence of Name_Error) and form.
+
+ procedure Delete_Tree (Directory : String);
+ -- Deletes an existing directory with name Directory. The directory and
+ -- all of its contents (possibly including other directories) are deleted.
+ -- The exception Name_Error is propagated if the string given as Directory
+ -- does not identify an existing directory. The exception Use_Error is
+ -- propagatedi f the external environment does not support the deletion of
+ -- the directory or some portion of its contents with the given name (in
+ -- the absence of Name_Error). If Use_Error is propagated, it is
+ -- unspecified if a portion of the contents of the directory are deleted.
+
+ procedure Delete_File (Name : String);
+ -- Deletes an existing ordinary or special file with Name. The exception
+ -- Name_Error is propagated if the string given as Name does not identify
+ -- an existing ordinary or special external file. The exception Use_Error
+ -- is propagated if the external environment does not support the deletion
+ -- of the file with the given name (in the absence of Name_Error).
+
+ procedure Rename (Old_Name, New_Name : String);
+ -- Renames an existing external file (including directories) with Old_Name
+ -- to New_Name. The exception Name_Error is propagated if the string given
+ -- as Old_Name does not identify an existing external file. The exception
+ -- Use_Error is propagated if the external environment does not support the
+ -- renaming of the file with the given name (in the absence of Name_Error).
+ -- In particular, Use_Error is propagated if a file or directory already
+ -- exists with New_Name.
+
+ procedure Copy_File
+ (Source_Name : String;
+ Target_Name : String;
+ Form : String := "");
+ -- Copies the contents of the existing external file with Source_Name
+ -- to Target_Name. The resulting external file is a duplicate of the source
+ -- external file. The Form can be used to give system-dependent
+ -- characteristics of the resulting external file; the interpretation of
+ -- the Form parameter is implementation-defined. Exception Name_Error is
+ -- propagated if the string given as Source_Name does not identify an
+ -- existing external ordinary or special file or if the string given as
+ -- Target_Name does not allow the identification of an external file.
+ -- The exception Use_Error is propagated if the external environment does
+ -- not support the creating of the file with the name given by Target_Name
+ -- and form given by Form, or copying of the file with the name given by
+ -- Source_Name (in the absence of Name_Error).
+
+
+ -- File and directory name operations:
+
+ function Full_Name (Name : String) return String;
+ -- Returns the full name corresponding to the file name specified by Name.
+ -- The exception Name_Error is propagated if the string given as Name does
+ -- not allow the identification of an external file (including directories
+ -- and special files).
+
+ function Simple_Name (Name : String) return String;
+ -- Returns the simple name portion of the file name specified by Name. The
+ -- exception Name_Error is propagated if the string given as Name does not
+ -- allow the identification of an external file (including directories and
+ -- special files).
+
+ function Containing_Directory (Name : String) return String;
+ -- Returns the name of the containing directory of the external file
+ -- (including directories) identified by Name. If more than one directory
+ -- can contain Name, the directory name returned is implementation-defined.
+ -- The exception Name_Error is propagated if the string given as Name does
+ -- not allow the identification of an external file. The exception
+ -- Use_Error is propagated if the external file does not have a containing
+ -- directory.
+
+ function Extension (Name : String) return String;
+ -- Returns the extension name corresponding to Name. The extension name is
+ -- a portion of a simple name (not including any separator characters),
+ -- typically used to identify the file class. If the external environment
+ -- does not have extension names, then the null string is returned.
+ -- The exception Name_Error is propagated if the string given as Name does
+ -- not allow the identification of an external file.
+
+ function Base_Name (Name : String) return String;
+ -- Returns the base name corresponding to Name. The base name is the
+ -- remainder of a simple name after removing any extension and extension
+ -- separators. The exception Name_Error is propagated if the string given
+ -- as Name does not allow the identification of an external file
+ -- (including directories and special files).
+
+ function Compose
+ (Containing_Directory : String := "";
+ Name : String;
+ Extension : String := "") return String;
+ -- Returns the name of the external file with the specified
+ -- Containing_Directory, Name, and Extension. If Extension is the null
+ -- string, then Name is interpreted as a simple name; otherwise Name is
+ -- interpreted as a base name. The exception Name_Error is propagated if
+ -- the string given as Containing_Directory is not null and does not allow
+ -- the identification of a directory, or if the string given as Extension
+ -- is not null and is not a possible extension, or if the string given as
+ -- Name is not a possible simple name (if Extension is null) or base name
+ -- (if Extension is non-null).
+
+
+ -- File and directory queries:
+
+ type File_Kind is (Directory, Ordinary_File, Special_File);
+ -- The type File_Kind represents the kind of file represented by an
+ -- external file or directory.
+
+ type File_Size is range 0 .. Long_Long_Integer'Last;
+ -- The type File_Size represents the size of an external file.
+
+ function Exists (Name : String) return Boolean;
+ -- Returns True if external file represented by Name exists, and False
+ -- otherwise. The exception Name_Error is propagated if the string given as
+ -- Name does not allow the identification of an external file (including
+ -- directories and special files).
+
+ function Kind (Name : String) return File_Kind;
+ -- Returns the kind of external file represented by Name. The exception
+ -- Name_Error is propagated if the string given as Name does not allow the
+ -- identification of an existing external file.
+
+ function Size (Name : String) return File_Size;
+ -- Returns the size of the external file represented by Name. The size of
+ -- an external file is the number of stream elements contained in the file.
+ -- If the external file is discontiguous (not all elements exist), the
+ -- result is implementation-defined. If the external file is not an
+ -- ordinary file, the result is implementation-defined. The exception
+ -- Name_Error is propagated if the string given as Name does not allow the
+ -- identification of an existing external file. The exception
+ -- Constraint_Error is propagated if the file size is not a value of type
+ -- File_Size.
+
+ function Modification_Time (Name : String) return Ada.Calendar.Time;
+ -- Returns the time that the external file represented by Name was most
+ -- recently modified. If the external file is not an ordinary file, the
+ -- result is implementation-defined. The exception Name_Error is propagated
+ -- if the string given as Name does not allow the identification of an
+ -- existing external file. The exception Use_Error is propagated if the
+ -- external environment does not support the reading the modification time
+ -- of the file with the name given by Name (in the absence of Name_Error).
+
+ -------------------------
+ -- Directory Searching --
+ -------------------------
+
+ type Directory_Entry_Type is limited private;
+ -- The type Directory_Entry_Type represents a single item in a directory.
+ -- These items can only be created by the Get_Next_Entry procedure in this
+ -- package. Information about the item can be obtained from the functions
+ -- declared in this package. A default initialized object of this type is
+ -- invalid; objects returned from Get_Next_Entry are valid.
+
+ type Filter_Type is array (File_Kind) of Boolean;
+ -- The type Filter_Type specifies which directory entries are provided from
+ -- a search operation. If the Directory component is True, directory
+ -- entries representing directories are provided. If the Ordinary_File
+ -- component is True, directory entries representing ordinary files are
+ -- provided. If the Special_File component is True, directory entries
+ -- representing special files are provided.
+
+ type Search_Type is limited private;
+ -- The type Search_Type contains the state of a directory search. A
+ -- default-initialized Search_Type object has no entries available
+ -- (More_Entries returns False).
+
+ procedure Start_Search
+ (Search : in out Search_Type;
+ Directory : String;
+ Pattern : String;
+ Filter : Filter_Type := (others => True));
+ -- Starts a search in the directory entry in the directory named by
+ -- Directory for entries matching Pattern. Pattern represents a file name
+ -- matching pattern. If Pattern is null, all items in the directory are
+ -- matched; otherwise, the interpretation of Pattern is
+ -- implementation-defined. Only items which match Filter will be returned.
+ -- After a successful call on Start_Search, the object Search may have
+ -- entries available, but it may have no entries available if no files or
+ -- directories match Pattern and Filter. The exception Name_Error is
+ -- propagated if the string given by Directory does not identify an
+ -- existing directory, or if Pattern does not allow the identification of
+ -- any possible external file or directory. The exception Use_Error is
+ -- propagated if the external environment does not support the searching
+ -- of the directory with the given name (in the absence of Name_Error).
+
+ procedure End_Search (Search : in out Search_Type);
+ -- Ends the search represented by Search. After a successful call on
+ -- End_Search, the object Search will have no entries available.
+
+ function More_Entries (Search : Search_Type) return Boolean;
+ -- Returns True if more entries are available to be returned by a call
+ -- to Get_Next_Entry for the specified search object, and False otherwise.
+
+ procedure Get_Next_Entry
+ (Search : in out Search_Type;
+ Directory_Entry : out Directory_Entry_Type);
+ -- Returns the next Directory_Entry for the search described by Search that
+ -- matches the pattern and filter. If no further matches are available,
+ -- Status_Error is raised. It is implementation-defined as to whether the
+ -- results returned by this routine are altered if the contents of the
+ -- directory are altered while the Search object is valid (for example, by
+ -- another program). The exception Use_Error is propagated if the external
+ -- environment does not support continued searching of the directory
+ -- represented by Search.
+
+ -------------------------------------
+ -- Operations on Directory Entries --
+ -------------------------------------
+
+ function Simple_Name (Directory_Entry : Directory_Entry_Type) return String;
+ -- Returns the simple external name of the external file (including
+ -- directories) represented by Directory_Entry. The format of the name
+ -- returned is implementation-defined. The exception Status_Error is
+ -- propagated if Directory_Entry is invalid.
+
+ function Full_Name (Directory_Entry : Directory_Entry_Type) return String;
+ -- Returns the full external name of the external file (including
+ -- directories) represented by Directory_Entry. The format of the name
+ -- returned is implementation-defined. The exception Status_Error is
+ -- propagated if Directory_Entry is invalid.
+
+ function Kind (Directory_Entry : Directory_Entry_Type) return File_Kind;
+ -- Returns the kind of external file represented by Directory_Entry. The
+ -- exception Status_Error is propagated if Directory_Entry is invalid.
+
+ function Size (Directory_Entry : Directory_Entry_Type) return File_Size;
+ -- Returns the size of the external file represented by Directory_Entry.
+ -- The size of an external file is the number of stream elements contained
+ -- in the file. If the external file is discontiguous (not all elements
+ -- exist), the result is implementation-defined. If the external file
+ -- represented by Directory_Entry is not an ordinary file, the result is
+ -- implementation-defined. The exception Status_Error is propagated if
+ -- Directory_Entry is invalid. The exception Constraint_Error is propagated
+ -- if the file size is not a value of type File_Size.
+
+ function Modification_Time
+ (Directory_Entry : Directory_Entry_Type) return Ada.Calendar.Time;
+ -- Returns the time that the external file represented by Directory_Entry
+ -- was most recently modified. If the external file represented by
+ -- Directory_Entry is not an ordinary file, the result is
+ -- implementation-defined. The exception Status_Error is propagated if
+ -- Directory_Entry is invalid. The exception Use_Error is propagated if
+ -- the external environment does not support the reading the modification
+ -- time of the file represented by Directory_Entry.
+
+ ----------------
+ -- Exceptions --
+ ----------------
+
+ Status_Error : exception renames Ada.IO_Exceptions.Status_Error;
+ Name_Error : exception renames Ada.IO_Exceptions.Name_Error;
+ Use_Error : exception renames Ada.IO_Exceptions.Use_Error;
+ Device_Error : exception renames Ada.IO_Exceptions.Device_Error;
+
+private
+ type Directory_Entry_Type is record
+ Is_Valid : Boolean := False;
+ Simple : Ada.Strings.Unbounded.Unbounded_String;
+ Full : Ada.Strings.Unbounded.Unbounded_String;
+ Kind : File_Kind;
+ end record;
+
+ -- The type Search_Data is defined in the body, so that the spec does not
+ -- depend on packages of the GNAT hierarchy.
+
+ type Search_Data;
+ type Search_Ptr is access Search_Data;
+
+ -- Search_Type need to be a controlled type, because it includes component
+ -- of type Dir_Type (in GNAT.Directory_Operations) that need to be closed
+ -- (if opened) during finalization.
+ -- The component need to be an access value, because Search_Data is not
+ -- fully defined in the spec.
+
+ type Search_Type is new Ada.Finalization.Controlled with record
+ Value : Search_Ptr;
+ end record;
+
+ procedure Finalize (Search : in out Search_Type);
+ -- Close the directory, if opened, and deallocate Value.
+
+ procedure End_Search (Search : in out Search_Type) renames Finalize;
+
+end Ada.Directories;
+
+