Anonymous user
Delete a file: Difference between revisions
m
whitespace and lang tags
(→{{header|Raven}}: ++ R) |
m (whitespace and lang tags) |
||
Line 4:
=={{header|Ada}}==
<lang ada>with Ada.Directories; use Ada.Directories;</lang>▼
▲with Ada.Directories; use Ada.Directories;
and then
<lang ada>Delete_File ("input.txt");
Delete_File ("/input.txt");
Delete_Tree ("docs");
Delete_Tree ("/docs");</lang>
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: <tt>scratch</tt> does not appear to do anything on [[ALGOL 68G]]. Also note that file names are Operating System dependent.
<pre>main:(
PROC remove = (STRING file name)INT:
BEGIN
Line 34 ⟶ 30:
remove("docs");
remove("/docs")
)</pre>▼
▲</pre>
=={{header|AutoHotkey}}==
<lang AutoHotkey>FileDelete, input.txt
FileDelete, \input.txt
FileRemoveDir, docs, 1
FileRemoveDir, \docs, 1</lang>
=={{header|AWK}}==
Assuming we are ona Unix/Linux or at least Cygwin system:
system("rm /input.txt");
system("rm -rf docs");
system("rm -rf /docs");</lang>
=={{header|C}}==
Line 161 ⟶ 153:
{{works with|Fortran|90 and later}}
I don't know a way of deleting directories in Fortran
CLOSE (UNIT=5, STATUS="DELETE")
OPEN (UNIT=5, FILE="/input.txt", STATUS="OLD") ! Root directory
CLOSE (UNIT=5, STATUS="DELETE")</lang>
=={{header|Haskell}}==
import System.Directory
Line 175 ⟶ 167:
removeDirectory "docs"
removeFile "/output.txt"
removeDirectory "/docs"</lang>
=={{header|Io}}==
Directory directoryNamed("docs") remove
RootDir := Directory clone setPath("/")
RootDir fileNamed("input.txt") remove
RootDir directoryNamed("docs") remove</lang>
=={{header|Java}}==
Line 208 ⟶ 200:
{{works with|UCB Logo}}
UCB Logo has no means to delete directories.
<lang logo>erasefile "input.txt
erasefile "/input.txt</logo>
=={{header|MAXScript}}==
Line 301 ⟶ 291:
=={{header|Ruby}}==
<lang ruby> File.delete("output.txt", "/output.txt")▼
▲ File.delete("output.txt", "/output.txt")
Dir.delete("docs")
Dir.delete("/docs")</lang>
=={{header|Slate}}==
Line 310 ⟶ 299:
(It will succeed deleting the directory if it is empty)
<lang slate>(File newNamed: 'input.txt') delete.
(File newNamed: '/input.txt') delete.
(Directory newNamed: 'docs') delete.
(Directory newNamed: '/docs') delete.</lang>
=={{header|Smalltalk}}==
Line 350 ⟶ 337:
=={{header|UNIX Shell}}==
rm input.txt
rm -rf /docs
rm /input.txt</lang>
=={{header|Vedit macro language}}==
Vedit allows using either '\' or '/' as directory separator character, it is automatically converted to the one used by the operating system.
<lang vedit>// In current directory
File_Delete("input.txt", OK)
File_Rmdir("docs")
Line 364 ⟶ 350:
// In the root directory
File_Delete("/input.txt", OK)
File_Rmdir("/docs")</lang>
=={{header|Visual Basic .NET}}==
|