1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 2001, Ada Core Technologies, Inc. --
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. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 -- This package provides a set of routines to deal with file extensions
31 with Ada
.Strings
.Fixed
;
34 package body MLib
.Fil
is
38 package Target
renames MLib
.Tgt
;
46 New_Ext
: String := "")
50 J
: constant Natural :=
51 Index
(Source
=> Filename
,
53 Going
=> Strings
.Backward
);
60 return Filename
& "." & New_Ext
;
65 return Head
(Filename
, J
- 1);
67 return Head
(Filename
, J
- 1) & '.' & New_Ext
;
76 function Get_Ext
(Filename
: in String) return String is
79 J
: constant Natural :=
80 Index
(Source
=> Filename
,
82 Going
=> Strings
.Backward
);
88 return Filename
(J
.. Filename
'Last);
96 function Is_Archive
(Filename
: String) return Boolean is
97 Ext
: constant String := Get_Ext
(Filename
);
100 return Target
.Is_Archive_Ext
(Ext
);
107 function Is_C
(Filename
: in String) return Boolean is
108 Ext
: constant String := Get_Ext
(Filename
);
111 return Target
.Is_C_Ext
(Ext
);
118 function Is_Obj
(Filename
: in String) return Boolean is
119 Ext
: constant String := Get_Ext
(Filename
);
122 return Target
.Is_Object_Ext
(Ext
);