File: gnatcoll-io-native.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 (158 lines) | stat: -rw-r--r-- 6,671 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
153
154
155
156
157
158
------------------------------------------------------------------------------
--                             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/>.                                          --
--                                                                          --
------------------------------------------------------------------------------

pragma Ada_05;

private with GNATCOLL.Path;

package GNATCOLL.IO.Native is

   type Native_File_Record is new File_Record with private;

   function Create (Path : FS_String) return File_Access;

   ------------------------------
   --  Utilities for native FS --
   ------------------------------

   function Current_Dir return File_Access;
   --  Return the current directory

   function Home_Dir return File_Access;
   --  Return the home directory

   function Get_Tmp_Directory return File_Access;
   --  Return the directory that can be used to store temporary
   --  files on the filesystem.

   function Get_Logical_Drives return File_Array;

   Local_Root_Dir : constant File_Access;

   ----------------------------
   -- Overridden from parent --
   ----------------------------

   overriding function Dispatching_Create
     (Ref : not null access Native_File_Record;
      Full_Path : FS_String) return File_Access;
   overriding function To_UTF8
     (Ref  : not null access Native_File_Record;
      Path : FS_String) return String;
   overriding function From_UTF8
     (Ref : not null access Native_File_Record;
      Path : String) return FS_String;
   overriding function Is_Local
     (File : Native_File_Record) return Boolean;
   overriding function Get_FS
     (File : not null access Native_File_Record) return FS_Type;
   overriding procedure Resolve_Symlinks
     (File : not null access Native_File_Record);
   overriding function Is_Regular_File
     (File : not null access Native_File_Record) return Boolean;
   function Size
     (File : not null access Native_File_Record) return Long_Integer;
   overriding function Is_Directory
     (File : not null access Native_File_Record) return Boolean;
   overriding function Is_Symbolic_Link
     (File : not null access Native_File_Record) return Boolean;
   overriding function File_Time_Stamp
     (File : not null access Native_File_Record) return Ada.Calendar.Time;
   overriding function Is_Writable
     (File : not null access Native_File_Record) return Boolean;
   overriding procedure Set_Writable
     (File  : not null access Native_File_Record;
      State : Boolean);
   overriding function Is_Readable
     (File : not null access Native_File_Record) return Boolean;
   overriding procedure Set_Readable
     (File  : not null access Native_File_Record;
      State : Boolean);
   overriding procedure Rename
     (From    : not null access Native_File_Record;
      Dest    : not null access Native_File_Record;
      Success : out Boolean);
   overriding procedure Copy
     (From    : not null access Native_File_Record;
      Dest    : FS_String;
      Success : out Boolean);
   overriding procedure Delete
     (File    : not null access Native_File_Record;
      Success : out Boolean);
   overriding function Read_Whole_File
     (File : not null access Native_File_Record)
      return GNAT.Strings.String_Access;
   overriding function Read_Whole_File
     (File : not null access Native_File_Record)
      return GNATCOLL.Strings.XString;
   overriding procedure Open_Write
     (File    : not null access Native_File_Record;
      Append  : Boolean := False;
      FD      : out GNAT.OS_Lib.File_Descriptor);
   overriding procedure Close
     (File    : not null access Native_File_Record;
      FD      : GNAT.OS_Lib.File_Descriptor;
      Success : out Boolean);
   overriding function Change_Dir
     (Dir : not null access Native_File_Record) return Boolean;
   overriding function Read_Dir
     (Dir            : not null access Native_File_Record;
      Dirs_Only      : Boolean := False;
      Files_Only     : Boolean := False)
      return GNAT.Strings.String_List;
   overriding function Make_Dir
     (Dir : not null access Native_File_Record; Recursive : Boolean)
      return Boolean;
   overriding procedure Remove_Dir
     (Dir       : not null access Native_File_Record;
      Recursive : Boolean;
      Success   : out Boolean);
   overriding procedure Copy_Dir
     (From    : not null access Native_File_Record;
      Dest    : FS_String;
      Success : out Boolean);
   overriding procedure Copy_File_Permissions
     (From, To : not null access Native_File_Record;
      Success  : out Boolean);

   package Codec is
      function To_UTF8 (Path : FS_String) return String;
      function To_UTF8 (Path : Wide_String) return String;
      function From_UTF8 (Path : String) return FS_String;
      function From_UTF8 (Path : String) return Wide_String;
   end Codec;
   --  Codec to translate a path to/from utf-8

private

   type Native_File_Record is new File_Record with null record;

   Local_Root_Dir : constant File_Access := new Native_File_Record'
     (Ref_Count  => 1,
      Full       => new FS_String'
        (GNATCOLL.Path.Path (GNATCOLL.Path.Local_FS, "", "", "")),
      Normalized => null,
      Normalized_And_Resolved => null,
      Kind       => Directory);

end GNATCOLL.IO.Native;