@@ -497,6 +497,45 @@ Formats all the arguments into a nice error message, utilizing the constructor o
497
497
498
498
---
499
499
500
+ ## ` is_file ` - Test if a path is a regular file
501
+
502
+ ### Status
503
+
504
+ Experimental
505
+
506
+ ### Description
507
+
508
+ This function checks if a specified file system path is a regular file.
509
+ It follows symbolic links and returns the status of the ` target ` .
510
+ It is designed to work across multiple platforms. On Windows, paths with both forward ` / ` and backward ` \ ` slashes are accepted.
511
+
512
+ ### Syntax
513
+
514
+ ` result = ` [[ stdlib_system(module): is_file (function)]] ` (path) `
515
+
516
+ ### Class
517
+
518
+ Function
519
+
520
+ ### Arguments
521
+
522
+ ` path ` : Shall be a character string containing the file system path to evaluate. It is an ` intent(in) ` argument.
523
+
524
+ ### Return values
525
+
526
+ The function returns a ` logical ` value:
527
+
528
+ - ` .true. ` if the path matches an existing regular file.
529
+ - ` .false. ` otherwise, or if path does not exist.
530
+
531
+ ### Example
532
+
533
+ ``` fortran
534
+ {!example/system/example_is_file.f90!}
535
+ ```
536
+
537
+ ---
538
+
500
539
## ` is_directory ` - Test if a path is a directory
501
540
502
541
### Status
@@ -506,6 +545,7 @@ Experimental
506
545
### Description
507
546
508
547
This function checks if a specified file system path is a directory.
548
+ It follows symbolic links and returns the status of the ` target ` .
509
549
It is designed to work across multiple platforms. On Windows, paths with both forward ` / ` and backward ` \ ` slashes are accepted.
510
550
511
551
### Syntax
@@ -535,6 +575,46 @@ The function returns a `logical` value:
535
575
536
576
---
537
577
578
+ ## ` is_symlink ` - Test if a path is a symbolic link.
579
+
580
+ ### Status
581
+
582
+ Experimental
583
+
584
+ ### Description
585
+
586
+ This function checks if a specified file system path is a symbolic link to either a file or a directory.
587
+ Use [[ stdlib_system(module): is_file (function)]] and [[ stdlib_system(module): is_directory (function)]] functions
588
+ to check further if the link is to a file or a directory respectively.
589
+ It is designed to work across multiple platforms. On Windows, paths with both forward ` / ` and backward ` \ ` slashes are accepted.
590
+
591
+ ### Syntax
592
+
593
+ ` result = ` [[ stdlib_system(module): is_symlink (function)]] ` (path) `
594
+
595
+ ### Class
596
+
597
+ Function
598
+
599
+ ### Arguments
600
+
601
+ ` path ` : Shall be a character string containing the file system path to evaluate. It is an ` intent(in) ` argument.
602
+
603
+ ### Return values
604
+
605
+ The function returns a ` logical ` value:
606
+
607
+ - ` .true. ` if the path matches an existing regular file.
608
+ - ` .false. ` otherwise, or if the path does not exist.
609
+
610
+ ### Example
611
+
612
+ ``` fortran
613
+ {!example/system/example_is_symlink.f90!}
614
+ ```
615
+
616
+ ---
617
+
538
618
## ` make_directory ` - Creates an empty directory
539
619
540
620
### Status
@@ -720,6 +800,54 @@ Subroutine
720
800
721
801
---
722
802
803
+ ## ` exists ` - Checks if a path exists in the filesystem
804
+
805
+ ### Status
806
+
807
+ Experimental
808
+
809
+ ### Description
810
+
811
+ This function makes a system call (syscall) to retrieve metadata for the specified path and determines its type.
812
+ It can distinguish between the following path types:
813
+
814
+ - Regular File
815
+ - Directory
816
+ - Symbolic Link
817
+
818
+ It returns a constant representing the detected path type, or ` type_unknown ` if the type cannot be determined.
819
+ Any encountered errors are handled using ` state_type ` .
820
+
821
+ ### Syntax
822
+
823
+ ` fs_type = [[stdlib_system(module):exists(function)]] (path [, err]) `
824
+
825
+ ### Class
826
+
827
+ Function
828
+
829
+ ### Arguments
830
+
831
+ ` path ` : Shall be a character string containing the path. It is an ` intent(in) ` argument.
832
+
833
+ ` err ` (optional): Shall be of type ` state_type ` , and is used for error handling. It is an ` optional, intent(out) ` argument.
834
+
835
+ ### Return values
836
+
837
+ ` fs_type ` : An ` intent(out), integer ` parameter indicating the type. The possible values are:
838
+ - ` fs_type_unknown ` : 0 => an unknown type
839
+ - ` fs_type_regular_file ` : 1 => a regular file
840
+ - ` fs_type_directory ` : 2 => a directory
841
+ - ` fs_type_symlink ` : 3 => a symbolic link
842
+
843
+ ` err ` (optional): It is an optional state return flag. If not requested and an error occurs, an ` FS_ERROR ` will trigger an error stop.
844
+
845
+ ``` fortran
846
+ {!example/system/example_exists.f90!}
847
+ ```
848
+
849
+ ---
850
+
723
851
## ` null_device ` - Return the null device file path
724
852
725
853
### Status
0 commit comments