4.2.37. GNATCOLL.OS.Stat

package GNATCOLL.OS.Stat is

   package UTF8 renames Ada.Strings.UTF_Encoding;
   package FS renames GNATCOLL.OS.FS;

   type File_Attributes is private;
   --  Record containing information about a file or directory on the
   --  filesystem

   function Stat
      (Path            : UTF8.UTF_8_String;
       Follow_Symlinks : Boolean := True)
      return File_Attributes;
   --  Retrieve file information about a file located at Path. If
   --  Follow_Symlinks is True then in case the file is a symlink the
   --  returned information is regarding the file which is the target of
   --  the symlink. If False, return the information about the symlink itself.
   --
   --  When passing a relative path, stat does not check that intermediate
   --  directories do exist. For example if file file.txt exists then stat
   --  returns success when calling Stat("non_existing_dir/../file.txt").
   --
   --  In case Path is not a valid UTF-8 string the function behaves as if the
   --  file does not exist.

   function Fstat (FD : FS.File_Descriptor) return File_Attributes;
   --  Retrieve file information for file descriptor FD.

   function Exists (Self : File_Attributes) return Boolean;
   --  Return True if the file exist on the filesystem

   function Is_File (Self : File_Attributes) return Boolean;
   --  Return True if the file is a regular file

   function Is_Directory (Self : File_Attributes) return Boolean;
   --  Return True if the file is a directory

   function Is_Symbolic_Link (Self : File_Attributes) return Boolean;
   --  Return True if the file is a symbolic link

   function Is_Executable (Self : File_Attributes) return Boolean;
   --  Return True if the file is executable

   function Is_Readable (Self : File_Attributes) return Boolean;
   --  Return True if the file is readable

   function Is_Writable (Self : File_Attributes) return Boolean;
   --  Return True if the file is writable

   function Is_Executable_File (Self : File_Attributes) return Boolean;
   --  Return True if the file is a regular file and is executable

   function Modification_Time (Self : File_Attributes) return Time;
   --  Return file modification time

   function Image (Self : File_Attributes) return String;
   --  String image of a File_Attributes structure

   function Length (Self : File_Attributes) return Long_Long_Integer;
   --  Return file length

   function New_File_Attributes
      (Exists        : Boolean;
       Writable      : Boolean;
       Readable      : Boolean;
       Executable    : Boolean;
       Symbolic_Link : Boolean;
       Regular       : Boolean;
       Directory     : Boolean;
       Stamp         : Time;
       Length        : Long_Long_Integer)
      return File_Attributes;
   --  Create manually a File_Attributes.
   --
   --  This function is for internal gnatcoll usage (used by GNATCOLL.OS.Dir).
   --  See File_Attributes private declaration for parameter meanings

end GNATCOLL.OS.Stat;