Anonymous user
Delete a file: Difference between revisions
no edit summary
(Ada solution added) |
No edit summary |
||
Line 4:
=={{header|Ada}}==
<lang ada>
with Ada.Directories; use Ada.Directories;
</
and then
<lang ada>
Delete_File ("input.txt");
Delete_File ("/input.txt");
Delete_Tree ("docs");
Delete_Tree ("/docs");
</
Naming conventions for the file path are [[OS]]-specific. The language does not specify the encoding of the file paths, the directory separators or brackets, the file extension delimiter, the file version delimiter and syntax. The example provided works under [[Linux]] and [[Windows]].
=={{header|ALGOL 68}}==
Note: <
<pre>
main:(
Line 39:
=={{header|C}}==
ISO C:
<lang c>#include <stdio.h>
int main() {
Line 47:
remove("/docs");
return 0;
}</
POSIX:
<lang c>#include <unistd.h>
int main() {
Line 58:
rmdir("/docs");
return 0;
}</
=={{header|D}}==
{{libheader|Tango}}
<lang d>import tango.io.Path;
void main() {
Line 69:
remove("docs");
remove("/docs");
}</
{{libheader|Tango}}
POSIX:
<lang d>import tango.stdc.posix.unistd;
void main() {
Line 80:
rmdir("docs");
rmdir("/docs");
}</
=={{header|Forth}}==
Line 115:
=={{header|Java}}==
<lang java>import java.util.File;
public class FileDeleteTest {
public static boolean deleteFile(String filename) {
Line 132:
test("directory", File.seperator + "docs" + File.seperator);
}
}</
=={{header|MAXScript}}==
Line 143:
=={{header|OCaml}}==
<lang ocaml>Sys.remove "input.txt";;
Sys.remove "/input.txt";;</
with the Unix library:
<lang ocaml>#load "unix.cma";;
Unix.unlink "input.txt";;
Unix.unlink "/input.txt";;
Unix.rmdir "docs";;
Unix.rmdir "/docs";;</
=={{header|Perl}}==
<lang perl>use File::Spec::Functions qw(catfile rootdir);
# here
unlink 'input.txt';
Line 161:
# root dir
unlink catfile rootdir, 'input.txt';
rmdir catfile rootdir, 'docs';</
'''Without Perl Modules'''
Line 183:
=={{header|Python}}==
<lang python>import os
# current directory
os.remove("output.txt")
Line 189:
# root directory
os.remove("/output.txt")
os.rmdir("/docs")</
=={{header|Raven}}==
|