Make directory path: Difference between revisions
Use functions from osfiles.s7i
m (→{{header|Wren}}: Changed to Wren S/H (future CLI version)) |
(Use functions from osfiles.s7i) |
||
Line 842:
=={{header|Seed7}}==
The library [http://seed7.sourceforge.net/libraries/
defines the functions [https://seed7.sourceforge.net/libraries/osfiles.htm#makeParentDirs(in_string) makeParentDirs], which creates the parent directories of the given path and [https://seed7.sourceforge.net/libraries/osfiles.htm#makeDir(in_string) makeDir], which creates a new directory. If the parent directory already exists a call of makeDir is sufficient and makeParentDirs is not necessary. The functions from osfiles.s7i use the [https://seed7.sourceforge.net/manual/os.htm#Standard_path_representation standard path representation] (the path delimiter is / and no drive letters exist). The function [https://seed7.sourceforge.net/libraries/osfiles.htm#convDosPath(in_string) convDosPath] converts a path with backslashes and drive letters to the standard path representation.
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "
const proc:
begin
makeParentDirs(dirPath);
if fileTypeSL(dirPath) <> FILE_DIR then
makeDir(dirPath);
end if;
end func;
const proc: main is func
begin
writeln("usage: makeDirectoryPath path");
elsif succeeds(makeDirectoryPath(convDosPath(argv(PROGRAM)[1]))) then
writeln("Directory path now exists");
else
writeln("Failed to create directory path");
end if;
end func;</syntaxhighlight>
|