File: gnatcoll-path.ads

package info (click to toggle)
libgnatcoll 18-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 5,068 kB
  • sloc: ada: 40,393; python: 354; ansic: 310; makefile: 245; sh: 31
file content (152 lines) | stat: -rw-r--r-- 5,646 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
------------------------------------------------------------------------------
--                             G N A T C O L L                              --
--                                                                          --
--                     Copyright (C) 2009-2017, AdaCore                     --
--                                                                          --
-- This library is free software;  you can redistribute it and/or modify it --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software  Foundation;  either version 3,  or (at your  option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
------------------------------------------------------------------------------

with GNATCOLL.VFS_Types; use GNATCOLL.VFS_Types;

private package GNATCOLL.Path is

   Invalid_Filesystem : exception;
   --  Raised when calling any of the below methods with FS_Unknown

   -------------------
   -- FS Properties --
   -------------------

   function Local_FS return FS_Type;
   pragma Inline (Local_FS);
   --  Get the local FS type

   function Is_Case_Sensitive (FS : FS_Type) return Boolean;
   --  Tell if FS is case sensitive

   function Has_Devices (FS : FS_Type) return Boolean;
   --  Tell if the Filesystem handles devices (hard disk letters for windows)

   function Multi_Unit_Index_Char (FS : FS_Type) return Character;
   --  The character used by GNAT when creating ALI files for multi-unit files
   --  on the given filesystem (this is generally '~' expect on VMS where it is
   --  set to '$').

   function Exe_Extension (FS : FS_Type) return FS_String;
   --  .exe on Windows, nothing on Unix

   ------------------
   -- Path queries --
   ------------------

   function Get_Root
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Return the root directory of the path

   function Is_Absolute_Path
     (FS   : FS_Type;
      Path : FS_String) return Boolean;
   --  Tell wether the path is absolute

   ------------------------
   -- Path manipulations --
   ------------------------

   function Path
     (FS     : FS_Type;
      Device : FS_String;
      Dir    : FS_String;
      File   : FS_String) return FS_String;
   --  Return a path composed of Device, Dir, and File

   function Equal
     (FS           : FS_Type;
      Path1, Path2 : FS_String) return Boolean;
   --  Tell if Path1 and Path2 are equivalent

   function To_Unix
     (FS          : FS_Type;
      Path        : FS_String;
      Cygwin_Path : Boolean := False) return FS_String;
   --  Translate a Path to unix style

   function From_Unix
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Translate a Path from unix style

   function File_Extension
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Return the file extension, including the last '.'

   function Base_Name
     (FS     : FS_Type;
      Path   : FS_String;
      Suffix : FS_String := "") return FS_String;
   --  Return the base file name

   function Base_Dir_Name
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Return the directory base name. Root directories will be returned
   --  as-is ("/", "C:\", "\\machine\service\")

   function Get_Parent
     (FS : FS_Type;
      Path : FS_String) return FS_String;
   --  Return the parent directory of Path. This differs from Dir_Name in that
   --  calling Get_Parent on a directory will return the directory's parent.

   function Dir_Name
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Return the directory path. Calling Dir_Name on a directory will return
   --  the directory itself.

   function Is_Dir_Name
     (FS   : FS_Type;
      Path : FS_String) return Boolean;
   --  Return true if Path denotes a directory path in FS (e.g. ends with a
   --  directory separator).

   function Ensure_Directory
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Return a directory path from furnished path.
   --  On Windows, for a path C:\path\to, this will return C:\path\to\
   --  On VMS, for a path disk:[path]to.dir, this will return disk:[path.to]

   function Device_Name
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Return the device of the path (if applicable). Empty string otherwise

   function Normalize
     (FS   : FS_Type;
      Path : FS_String) return FS_String;
   --  Replace every ./ or ../ items of the path

   function Relative_Path
     (FS   : FS_Type;
      Ref  : FS_String;
      Path : FS_String) return FS_String;
   --  Return the path of Path relative to Ref

end GNATCOLL.Path;