os_object Derived Type

type, public :: os_object

type~~os_object~~InheritsGraph type~os_object os_object type~error_object error_object type~error_object->type~os_object error
Help


OS object class.

This class is designed as an helper for performing system calls, e.g. make directory, copy files, etc…

Inherited By

type~~os_object~~InheritedByGraph type~os_object os_object type~simulation_object simulation_object type~os_object->type~simulation_object os
Help

Source Code


Components

TypeVisibility AttributesNameInitial
character(len=:), public, allocatable:: cp_dir_command

Copy directory command.

character(len=:), public, allocatable:: cp_file_command

Copy file command.

type(error_object), public :: error

Error handler.

character(len=:), public, allocatable:: mkdir_command

Make directory command.

character(len=:), public, allocatable:: path_separator

Path seperator, e.g. "/" for unix-like systems.

character(len=:), public, allocatable:: rm_dir_command

Remove directory command.

character(len=:), public, allocatable:: rm_file_command

Remove file command.


Type-Bound Procedures

generic, public :: assignment(=) => os_assign_os

Overload =.

  • private pure subroutine os_assign_os(lhs, rhs)

    Operator =.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: lhs

    Left hand side.

    type(os_object), intent(in) :: rhs

    Right hand side.

procedure, public, pass(self) :: cp

Copy files/directories.

  • private subroutine cp(self, file_name, dir_name)

    Copy files/directories.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: self

    OS.

    character(len=*), intent(in), optional :: file_name

    File name.

    character(len=*), intent(in), optional :: dir_name

    Dir name.

procedure, public, pass(self) :: destroy

Destroy OS… not your :-)

  • private elemental subroutine destroy(self)

    Destroy OS… not your :-)

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: self

    OS.

procedure, public, pass(self) :: initialize

Initialze OS.

  • private elemental subroutine initialize(self, system)

    Initialize OS.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: self

    OS.

    character(len=*), intent(in), optional :: system

    System name, valid [unix, windows].

procedure, public, pass(self) :: initialize_unix

Initialze OS as unix-like system.

  • private elemental subroutine initialize_unix(self)

    Initialize OS as unix-like system.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: self

    OS.

procedure, public, pass(self) :: initialize_windows

Initialze OS as windows-like system.

  • private elemental subroutine initialize_windows(self)

    Initialize OS as windows-like system.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: self

    OS.

procedure, public, pass(self) :: mkdir

Make directory.

  • private subroutine mkdir(self, dir_name)

    Make directoriy.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: self

    OS.

    character(len=*), intent(in) :: dir_name

    Dir name.

procedure, public, pass(lhs) :: os_assign_os

Operator =.

  • private pure subroutine os_assign_os(lhs, rhs)

    Operator =.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: lhs

    Left hand side.

    type(os_object), intent(in) :: rhs

    Right hand side.

procedure, public, pass(self) :: rm

Remove files/directories.

  • private subroutine rm(self, file_name, dir_name)

    Remove files/directories.

    Arguments

    Type IntentOptional AttributesName
    class(os_object), intent(inout) :: self

    OS.

    character(len=*), intent(in), optional :: file_name

    File name.

    character(len=*), intent(in), optional :: dir_name

    Dir name.

Source Code

type :: os_object
   !< OS object class.
   !<
   !< This class is designed as an helper for performing system calls, e.g. make directory, copy files, etc...
   type(error_object)            :: error           !< Error handler.
   character(len=:), allocatable :: path_separator  !< Path seperator, e.g. "/" for unix-like systems.
   character(len=:), allocatable :: cp_dir_command  !< Copy directory command.
   character(len=:), allocatable :: cp_file_command !< Copy file command.
   character(len=:), allocatable :: mkdir_command   !< Make directory command.
   character(len=:), allocatable :: rm_dir_command  !< Remove directory command.
   character(len=:), allocatable :: rm_file_command !< Remove file command.
   contains
      ! public methods
      procedure, pass(self) :: cp         !< Copy files/directories.
      procedure, pass(self) :: destroy    !< Destroy OS... not your :-)
      procedure, pass(self) :: initialize !< Initialze OS.
      procedure, pass(self) :: mkdir      !< Make directory.
      procedure, pass(self) :: rm         !< Remove files/directories.
      ! operators
      generic :: assignment(=) => os_assign_os !< Overload `=`.
      ! private methods
      procedure, pass(self) :: initialize_unix    !< Initialze OS as unix-like system.
      procedure, pass(self) :: initialize_windows !< Initialze OS as windows-like system.
      procedure, pass(lhs)  :: os_assign_os       !< Operator `=`.
endtype os_object