Skip to content

Commit 1bd58b7

Browse files
committed
added specs
1 parent 8a10f26 commit 1bd58b7

File tree

2 files changed

+178
-1
lines changed

2 files changed

+178
-1
lines changed

doc/specs/stdlib_system.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,180 @@ The file is removed from the filesystem if the operation is successful. If the o
532532
```fortran
533533
{!example/system/example_delete_file.f90!}
534534
```
535+
536+
## `joinpath` - Joins the provided paths according to the OS
537+
538+
### Status
539+
540+
Experimental
541+
542+
### Description
543+
544+
This interface joins the paths provided to it according to the platform specific path-separator.
545+
i.e `\` for windows and `/` for others
546+
547+
### Syntax
548+
549+
`res = [[stdlib_system(module):joinpath(interface)]] (p1, p2)`
550+
`res = [[stdlib_system(module):joinpath(interface)]] (p)`
551+
552+
### Class
553+
Pure function
554+
555+
### Arguments
556+
557+
`p1, p2`: Shall be a character string. It is an `intent(in)` argument.
558+
or
559+
`p`: Shall be a list of character strings. `intent(in)` argument.
560+
561+
### Return values
562+
563+
The resultant path.
564+
565+
### Example
566+
567+
```fortran
568+
{!example/system/example_path_1.f90!}
569+
```
570+
571+
## `operator(/)`
572+
573+
Join two paths according to the platform specific path-separator,
574+
Behavior exactly similar to `joinpath`
575+
576+
### Status
577+
578+
Experimental
579+
580+
### Syntax
581+
582+
`p = lval + rval`
583+
584+
### Class
585+
586+
Pure function.
587+
588+
### Arguments
589+
590+
`lval`: A character string, `intent(in)`.
591+
`rval`: A character string, `intent(in)`.
592+
593+
### Result value
594+
595+
The result is an `allocatable` character string
596+
597+
#### Example
598+
599+
```fortran
600+
{!example/system/example_path_1.f90!}
601+
```
602+
603+
## `splitpath` - splits a path immediately following the last separator
604+
605+
### Status
606+
607+
Experimental
608+
609+
### Description
610+
611+
This subroutine splits a path immediately following the last separator after removing the trailing separators
612+
splitting it into most of the times a directory and a file name.
613+
614+
### Syntax
615+
616+
`call [[stdlib_system(module):splitpath(interface)]] (p, head, tail)`
617+
618+
### Class
619+
Subroutine
620+
621+
### Arguments
622+
623+
`p`: A character string containing the path to be split. `intent(in)`
624+
`head`: The first part of the path. `allocatable, intent(out)`
625+
`tail`: The rest part of the path. `allocatable, intent(out)`
626+
627+
### Behavior
628+
629+
- If `p` is empty, `head` is set to `.` and `tail` is empty
630+
- If `p` consists entirely of path-separators. `head` is set to the path-separator and `tail` is empty
631+
- `head` ends in a path-separator iff and only if `p` appears to be a root directory or child of one
632+
633+
### Return values
634+
635+
The splitted path. `head` and `tail`.
636+
637+
### Example
638+
639+
```fortran
640+
{!example/system/example_path_1.f90!}
641+
```
642+
643+
## `basename` - The last part of a path
644+
645+
### Status
646+
647+
Experimental
648+
649+
### Description
650+
651+
This function returns the last part of a path after removing trailing path separators.
652+
653+
### Syntax
654+
655+
`res = [[stdlib_system(module):basename(interface)]] (p)`
656+
657+
### Class
658+
Function
659+
660+
### Arguments
661+
662+
`p`: the path, a character string, `intent(in)`
663+
664+
### Behavior
665+
666+
- The `tail` of `stdlib_system(module):splitpath(interface)` is exactly what is returned. Same Behavior.
667+
668+
### Return values
669+
670+
A character string.
671+
672+
### Example
673+
674+
```fortran
675+
{!example/system/example_path_1.f90!}
676+
```
677+
678+
## `dirname` - Everything except the last part of the path
679+
680+
### Status
681+
682+
Experimental
683+
684+
### Description
685+
686+
This function returns everything except the last part of a path.
687+
688+
### Syntax
689+
690+
`res = [[stdlib_system(module):dirname(interface)]] (p)`
691+
692+
### Class
693+
Function
694+
695+
### Arguments
696+
697+
`p`: the path, a character string, `intent(in)`
698+
699+
### Behavior
700+
701+
- The `head` of `stdlib_system(module):splitpath(interface)` is exactly what is returned. Same Behavior.
702+
703+
### Return values
704+
705+
A character string.
706+
707+
### Example
708+
709+
```fortran
710+
{!example/system/example_path_1.f90!}
711+
```

src/stdlib_system.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ end function join_op
608608
!! If the path is empty `head`='.' and tail=''
609609
!! If the path only consists of separators, `head` is set to the separator and tail is empty
610610
!! If the path is a root directory, `head` is set to that directory and tail is empty
611-
!! `head` ends with a path-separator iff the path appears to be a root directory
611+
!! `head` ends with a path-separator iff the path appears to be a root directory or a child of the root directory
612612
module subroutine splitpath(p, head, tail)
613613
character(*), intent(in) :: p
614614
character(:), allocatable, intent(out) :: head, tail

0 commit comments

Comments
 (0)