File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,23 @@ module stdlib_system
8181public :: elapsed
8282public :: is_windows
8383
84+ ! ! version: experimental
85+ ! !
86+ ! ! Returns the file path of the null device, which discards all data written to it.
87+ ! ! ([Specification](../page/specs/stdlib_system.html#null_device-return-the-null-device-file-path))
88+ ! !
89+ ! ! ### Summary
90+ ! ! Function that provides the file path of the null device appropriate for the current operating system.
91+ ! !
92+ ! ! ### Description
93+ ! !
94+ ! ! The null device is a special file that discards all data written to it and always reads as
95+ ! ! an empty file. This function returns the null device path, adapted for the operating system in use.
96+ ! !
97+ ! ! On Windows, this is `NUL`. On UNIX-like systems, this is `/dev/null`.
98+ ! !
99+ public :: null_device
100+
84101! CPU clock ticks storage
85102integer , parameter , private :: TICKS = int64
86103integer , parameter , private :: RTICKS = dp
@@ -618,4 +635,17 @@ pure function OS_NAME(os)
618635 end select
619636end function OS_NAME
620637
638+ ! > Return the file path of the null device for the current operating system.
639+ function null_device () result(path)
640+ ! > File path of the null device
641+ character (:), allocatable :: path
642+
643+ if (OS_TYPE()==OS_WINDOWS) then
644+ path = ' NUL'
645+ else
646+ path = ' /dev/null'
647+ end if
648+
649+ end function null_device
650+
621651end module stdlib_system
You can’t perform that action at this time.
0 commit comments