Commit 32c65fc0 by Vincent Celier Committed by Arnaud Charlet

a-direct.adb (Duration_To_Time, [...]): New Unchecked_Conversion functions.

2006-02-13  Vincent Celier  <celier@adacore.com>

	* a-direct.adb (Duration_To_Time, OS_Time_To_Long_Integer): New
	Unchecked_Conversion functions.
	(Modification_Time): Use direct conversion of OS_Time to Calendar time
	when OpenVMS returns False.

	* a-dirval-mingw.adb, a-dirval-vms.adb, a-dirval.ads,
	a-dirval.adb (OpenVMS): New Boolean function

From-SVN: r111051
parent 463af61d
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
with Ada.Directories.Validity; use Ada.Directories.Validity; with Ada.Directories.Validity; use Ada.Directories.Validity;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Unchecked_Deallocation; with Ada.Unchecked_Deallocation;
with Ada.Unchecked_Conversion;
with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Characters.Handling; use Ada.Characters.Handling;
with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.Directory_Operations; use GNAT.Directory_Operations;
...@@ -45,6 +46,13 @@ with System; ...@@ -45,6 +46,13 @@ with System;
package body Ada.Directories is package body Ada.Directories is
function Duration_To_Time is new
Ada.Unchecked_Conversion (Duration, Ada.Calendar.Time);
function OS_Time_To_Long_Integer is new
Ada.Unchecked_Conversion (OS_Time, Long_Integer);
-- These two unchecked conversions are used in function Modification_Time
-- to convert an OS_Time to a Calendar.Time.
type Search_Data is record type Search_Data is record
Is_Valid : Boolean := False; Is_Valid : Boolean := False;
Name : Ada.Strings.Unbounded.Unbounded_String; Name : Ada.Strings.Unbounded.Unbounded_String;
...@@ -54,10 +62,10 @@ package body Ada.Directories is ...@@ -54,10 +62,10 @@ package body Ada.Directories is
Entry_Fetched : Boolean := False; Entry_Fetched : Boolean := False;
Dir_Entry : Directory_Entry_Type; Dir_Entry : Directory_Entry_Type;
end record; end record;
-- Comment required ??? -- The current state of a search
Empty_String : constant String := (1 .. 0 => ASCII.NUL); Empty_String : constant String := (1 .. 0 => ASCII.NUL);
-- Comment required ??? -- Empty string, returned by function Extension when there is no extension
procedure Free is new Ada.Unchecked_Deallocation (Search_Data, Search_Ptr); procedure Free is new Ada.Unchecked_Deallocation (Search_Data, Search_Ptr);
...@@ -725,6 +733,8 @@ package body Ada.Directories is ...@@ -725,6 +733,8 @@ package body Ada.Directories is
Minute : Minute_Type; Minute : Minute_Type;
Second : Second_Type; Second : Second_Type;
Result : Ada.Calendar.Time;
begin begin
-- First, the invalid cases -- First, the invalid cases
...@@ -733,14 +743,27 @@ package body Ada.Directories is ...@@ -733,14 +743,27 @@ package body Ada.Directories is
else else
Date := File_Time_Stamp (Name); Date := File_Time_Stamp (Name);
-- ???? We need to be able to convert OS_Time to Ada.Calendar.Time
-- For now, use the component of the OS_Time to create the
-- Calendar.Time value.
GM_Split (Date, Year, Month, Day, Hour, Minute, Second); -- ??? This implementation should be revisited when AI 00351 has
-- implemented.
if OpenVMS then
-- On OpenVMS, OS_Time is in local time
return Ada.Calendar.Time_Of GM_Split (Date, Year, Month, Day, Hour, Minute, Second);
(Year, Month, Day, Duration (Second + 60 * (Minute + 60 * Hour)));
return Ada.Calendar.Time_Of
(Year, Month, Day,
Duration (Second + 60 * (Minute + 60 * Hour)));
else
-- On Unix and Windows, OS_Time is in GMT
Result :=
Duration_To_Time (Duration (OS_Time_To_Long_Integer (Date)));
return Result;
end if;
end if; end if;
end Modification_Time; end Modification_Time;
......
...@@ -153,4 +153,13 @@ package body Ada.Directories.Validity is ...@@ -153,4 +153,13 @@ package body Ada.Directories.Validity is
end if; end if;
end Is_Valid_Simple_Name; end Is_Valid_Simple_Name;
-------------
-- OpenVMS --
-------------
function OpenVMS return Boolean is
begin
return False;
end OpenVMS;
end Ada.Directories.Validity; end Ada.Directories.Validity;
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
-- B o d y -- -- B o d y --
-- (VMS Version) -- -- (VMS Version) --
-- -- -- --
-- Copyright (C) 2004 Free Software Foundation, Inc. -- -- Copyright (C) 2004-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -180,4 +180,13 @@ package body Ada.Directories.Validity is ...@@ -180,4 +180,13 @@ package body Ada.Directories.Validity is
return True; return True;
end Is_Valid_Simple_Name; end Is_Valid_Simple_Name;
-------------
-- OpenVMS --
-------------
function OpenVMS return Boolean is
begin
return True;
end OpenVMS;
end Ada.Directories.Validity; end Ada.Directories.Validity;
...@@ -94,4 +94,13 @@ package body Ada.Directories.Validity is ...@@ -94,4 +94,13 @@ package body Ada.Directories.Validity is
return True; return True;
end Is_Valid_Simple_Name; end Is_Valid_Simple_Name;
-------------
-- OpenVMS --
-------------
function OpenVMS return Boolean is
begin
return False;
end OpenVMS;
end Ada.Directories.Validity; end Ada.Directories.Validity;
...@@ -45,4 +45,7 @@ private package Ada.Directories.Validity is ...@@ -45,4 +45,7 @@ private package Ada.Directories.Validity is
function Is_Path_Name_Case_Sensitive return Boolean; function Is_Path_Name_Case_Sensitive return Boolean;
-- Returns True if file and path names are case-sensitive -- Returns True if file and path names are case-sensitive
function OpenVMS return Boolean;
-- Return True when OS is OpenVMS
end Ada.Directories.Validity; end Ada.Directories.Validity;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment