blob: 9dbfcf77d766f0c4714ef703e231430ee1b56d38 [file] [log] [blame]
Nico Huberf03ef4f2017-03-04 13:57:09 +01001--
2-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>
3--
4-- This program is free software; you can redistribute it and/or modify
5-- it under the terms of the GNU General Public License as published by
6-- the Free Software Foundation; either version 2 of the License, or
7-- (at your option) any later version.
8--
9-- This program is distributed in the hope that it will be useful,
10-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-- GNU General Public License for more details.
13--
14
15package HW.File is
16
Nico Hubera43b1ee2017-07-09 15:40:25 +020017 --
Nico Huberf03ef4f2017-03-04 13:57:09 +010018 -- Map a file's content into our address space
19 --
Nico Huber967dd0d2017-07-09 15:51:08 +020020 -- If `Map_Copy` is `False`, `Len` bytes at `Offset` from the start
21 -- of the file given by `Path` should be mapped into the application's
22 -- address space using mmap().
Nico Hubera43b1ee2017-07-09 15:40:25 +020023 --
24 -- If `Map_Copy` is `True`, anonymous memory should be mapped instead
25 -- and be filled with a copy of the file's content using read().
26 --
Nico Huber967dd0d2017-07-09 15:51:08 +020027 -- If `Len` is zero, the whole file should be mapped.
28 --
Nico Huberf03ef4f2017-03-04 13:57:09 +010029 procedure Map
Nico Hubera43b1ee2017-07-09 15:40:25 +020030 (Addr : out Word64;
31 Path : in String;
Nico Huber967dd0d2017-07-09 15:51:08 +020032 Len : in Natural := 0;
33 Offset : in Natural := 0;
Nico Huberf03ef4f2017-03-04 13:57:09 +010034 Readable : in Boolean := False;
35 Writable : in Boolean := False;
36 Map_Copy : in Boolean := False;
37 Success : out Boolean)
38 with
39 Pre => (Readable or Writable) and
40 (if Map_Copy then Readable and not Writable);
41
42end HW.File;