Skip to content

Commit 7346b8e

Browse files
committed
move doc to stdlib_system
1 parent be1274b commit 7346b8e

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

doc/specs/stdlib_io.md

-54
Original file line numberDiff line numberDiff line change
@@ -302,57 +302,3 @@ Exceptions trigger an `error stop` unless the optional `err` argument is provide
302302
{!example/io/example_get_file.f90!}
303303
```
304304

305-
## `delete_file` - Delete a file
306-
307-
### Status
308-
309-
Experimental
310-
311-
### Description
312-
313-
This subroutine deletes a specified file from the filesystem. It ensures that the file exists and is not a directory before attempting deletion.
314-
If the file cannot be deleted due to permissions, being a directory, or other issues, an error is raised.
315-
The function provides an optional error-handling mechanism via the `state_type` class. If the `err` argument is not provided, exceptions will trigger an `error stop`.
316-
317-
### Syntax
318-
319-
`call [[stdlib_fs(module):delete_file(subroutine)]] (path [, err])`
320-
321-
### Class
322-
Subroutine
323-
324-
### Arguments
325-
326-
`path`: Shall be a character string containing the path to the file to be deleted. It is an `intent(in)` argument.
327-
328-
`err` (optional): Shall be a `type(state_type)` variable for error handling. If provided, errors are returned as a state object. If not provided, the program stops execution on error.
329-
330-
### Behavior
331-
332-
- Checks if the file exists. If not, an error is raised.
333-
- Ensures the path is not a directory before deletion.
334-
- Attempts to delete the file, raising an error if unsuccessful.
335-
336-
### Return values
337-
338-
The file is removed from the filesystem if the operation is successful. If the operation fails, an error is raised.
339-
340-
### Example
341-
342-
```fortran
343-
program example_delete_file
344-
use stdlib_fs
345-
implicit none
346-
347-
type(state_type) :: err
348-
349-
! Delete a file with error handling
350-
call delete_file("example.txt", err)
351-
352-
if (err%error()) then
353-
print *, "Failed to delete file:", err%print()
354-
else
355-
print *, "File deleted successfully."
356-
end if
357-
end program example_delete_file
358-
```

doc/specs/stdlib_system.md

+54
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,57 @@ None.
492492
{!example/system/example_null_device.f90!}
493493
```
494494

495+
## `delete_file` - Delete a file
496+
497+
### Status
498+
499+
Experimental
500+
501+
### Description
502+
503+
This subroutine deletes a specified file from the filesystem. It ensures that the file exists and is not a directory before attempting deletion.
504+
If the file cannot be deleted due to permissions, being a directory, or other issues, an error is raised.
505+
The function provides an optional error-handling mechanism via the `state_type` class. If the `err` argument is not provided, exceptions will trigger an `error stop`.
506+
507+
### Syntax
508+
509+
`call [[stdlib_fs(module):delete_file(subroutine)]] (path [, err])`
510+
511+
### Class
512+
Subroutine
513+
514+
### Arguments
515+
516+
`path`: Shall be a character string containing the path to the file to be deleted. It is an `intent(in)` argument.
517+
518+
`err` (optional): Shall be a `type(state_type)` variable for error handling. If provided, errors are returned as a state object. If not provided, the program stops execution on error.
519+
520+
### Behavior
521+
522+
- Checks if the file exists. If not, an error is raised.
523+
- Ensures the path is not a directory before deletion.
524+
- Attempts to delete the file, raising an error if unsuccessful.
525+
526+
### Return values
527+
528+
The file is removed from the filesystem if the operation is successful. If the operation fails, an error is raised.
529+
530+
### Example
531+
532+
```fortran
533+
program example_delete_file
534+
use stdlib_fs
535+
implicit none
536+
537+
type(state_type) :: err
538+
539+
! Delete a file with error handling
540+
call delete_file("example.txt", err)
541+
542+
if (err%error()) then
543+
print *, "Failed to delete file:", err%print()
544+
else
545+
print *, "File deleted successfully."
546+
end if
547+
end program example_delete_file
548+
```

0 commit comments

Comments
 (0)