| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT RUN-TIME COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- A D A . D I R E C T O R I E S . V A L I D I T Y -- |
| 6 |
-- -- |
| 7 |
-- B o d y -- |
| 8 |
-- (POSIX Version) -- |
| 9 |
-- -- |
| 10 |
-- Copyright (C) 2004-2025, Free Software Foundation, Inc. -- |
| 11 |
-- -- |
| 12 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 13 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 14 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 15 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 16 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 17 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 18 |
-- -- |
| 19 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 20 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 21 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 22 |
-- -- |
| 23 |
-- You should have received a copy of the GNU General Public License and -- |
| 24 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 25 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 26 |
-- <http://www.gnu.org/licenses/>. -- |
| 27 |
-- -- |
| 28 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 29 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 30 |
-- -- |
| 31 |
------------------------------------------------------------------------------ |
| 32 |
|
| 33 |
-- This is the POSIX version of this package |
| 34 |
|
| 35 |
package body Ada.Directories.Validity is |
| 36 |
|
| 37 |
--------------------------------- |
| 38 |
-- Is_Path_Name_Case_Sensitive -- |
| 39 |
--------------------------------- |
| 40 |
|
| 41 |
function Is_Path_Name_Case_Sensitive return Boolean is |
| 42 |
begin |
| 43 |
return True; |
| 44 |
end Is_Path_Name_Case_Sensitive; |
| 45 |
|
| 46 |
------------------------ |
| 47 |
-- Is_Valid_Path_Name -- |
| 48 |
------------------------ |
| 49 |
|
| 50 |
function Is_Valid_Path_Name (Name : String) return Boolean is |
| 51 |
begin |
| 52 |
-- A path name cannot be empty and cannot contain any NUL character |
| 53 |
|
| 54 |
if Name'Length = 0 then |
| 55 |
return False; |
| 56 |
|
| 57 |
else |
| 58 |
for J in Name'Range loop |
| 59 |
if Name (J) = ASCII.NUL then |
| 60 |
return False; |
| 61 |
end if; |
| 62 |
end loop; |
| 63 |
end if; |
| 64 |
|
| 65 |
-- If Name does not contain any NUL character, it is valid |
| 66 |
|
| 67 |
return True; |
| 68 |
end Is_Valid_Path_Name; |
| 69 |
|
| 70 |
-------------------------- |
| 71 |
-- Is_Valid_Simple_Name -- |
| 72 |
-------------------------- |
| 73 |
|
| 74 |
function Is_Valid_Simple_Name (Name : String) return Boolean is |
| 75 |
begin |
| 76 |
-- A file name cannot be empty and cannot contain a slash ('/') or |
| 77 |
-- the NUL character. |
| 78 |
|
| 79 |
if Name'Length = 0 then |
| 80 |
return False; |
| 81 |
|
| 82 |
else |
| 83 |
for J in Name'Range loop |
| 84 |
if Name (J) = '/' or else Name (J) = ASCII.NUL then |
| 85 |
return False; |
| 86 |
end if; |
| 87 |
end loop; |
| 88 |
end if; |
| 89 |
|
| 90 |
-- If Name does not contain any slash or NUL, it is valid |
| 91 |
|
| 92 |
return True; |
| 93 |
end Is_Valid_Simple_Name; |
| 94 |
|
| 95 |
------------- |
| 96 |
-- Windows -- |
| 97 |
------------- |
| 98 |
|
| 99 |
function Windows return Boolean is |
| 100 |
begin |
| 101 |
return False; |
| 102 |
end Windows; |
| 103 |
|
| 104 |
end Ada.Directories.Validity; |