/usr/share/ada/adainclude/aws/aws-resources-files.adb is in libaws3.2.0-dev 3.2.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2002-2012, 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 --
-- MERCHANTABILITY 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 Ada.Directories;
with Ada.IO_Exceptions;
with AWS.Resources.Streams.Disk;
with AWS.Resources.Streams.ZLib;
with ZLib;
package body AWS.Resources.Files is
use Ada;
use type Directories.File_Kind;
-----------
-- Exist --
-----------
function Exist (Name : String) return File_Instance is
VP, VG : Boolean := False;
begin
if Is_GZip (Name) then
VG := Utils.Is_Regular_File (Name);
VP := Utils.Is_Regular_File
(Name (Name'First .. Name'Last - GZip_Ext'Length));
else
VP := Utils.Is_Regular_File (Name);
VG := Utils.Is_Regular_File (Name & GZip_Ext);
end if;
if VG and then VP then
return Both;
elsif VG then
return GZip;
elsif VP then
return Plain;
else
return None;
end if;
end Exist;
---------------
-- File_Size --
---------------
function File_Size (Name : String) return Utils.File_Size_Type is
begin
if Utils.Is_Regular_File (Name) then
return Utils.File_Size (Name);
else
if Is_GZip (Name) then
raise Resource_Error;
else
return File_Size (Name & GZip_Ext);
end if;
end if;
end File_Size;
--------------------
-- File_Timestamp --
--------------------
function File_Timestamp (Name : String) return Ada.Calendar.Time is
begin
if Utils.Is_Regular_File (Name) then
return Directories.Modification_Time (Name);
else
if Is_GZip (Name) then
raise Resource_Error;
else
return File_Timestamp (Name & GZip_Ext);
end if;
end if;
end File_Timestamp;
---------------------
-- Is_Regular_File --
---------------------
function Is_Regular_File (Name : String) return Boolean is
begin
return Utils.Is_Regular_File (Name)
or else
(not Is_GZip (Name)
and then Utils.Is_Regular_File (Name & GZip_Ext));
end Is_Regular_File;
----------
-- Open --
----------
procedure Open
(File : out File_Type;
Name : String;
Form : String := "";
GZip : in out Boolean)
is
use type AWS.Resources.Streams.Stream_Access;
File_Kind : constant Resources.File_Instance := Resources.Exist (Name);
Stream : AWS.Resources.Streams.Stream_Access;
procedure Open_File (Name : String);
---------------
-- Open_File --
---------------
procedure Open_File (Name : String) is
begin
Stream := new AWS.Resources.Streams.Disk.Stream_Type;
AWS.Resources.Streams.Disk.Open
(AWS.Resources.Streams.Disk.Stream_Type (Stream.all), Name, Form);
end Open_File;
begin
if Is_GZip (Name) then
-- Don't try to open file Name & ".gz.gz"
case File_Kind is
when Both | Resources.GZip =>
GZip := False;
Open_File (Name);
when Plain | None =>
raise IO_Exceptions.Name_Error;
end case;
elsif GZip then
case File_Kind is
when Both | Resources.GZip =>
Open_File (Name & ".gz");
when Plain =>
Open_File (Name);
GZip := False;
when None =>
raise IO_Exceptions.Name_Error;
end case;
else
case File_Kind is
when Both | Plain =>
Open_File (Name);
when Resources.GZip =>
Open_File (Name & ".gz");
Stream := Streams.ZLib.Inflate_Create
(Stream, Header => ZLib.GZip);
when None =>
raise IO_Exceptions.Name_Error;
end case;
end if;
Streams.Create (File, Stream);
end Open;
procedure Open
(File : out File_Type;
Name : String;
Form : String := "")
is
GZip : Boolean := False;
begin
Open (File, Name, Form, GZip);
end Open;
end AWS.Resources.Files;
|