Jump to content

Delete a file: Difference between revisions

m
whitespace and lang tags
m (whitespace and lang tags)
Line 4:
 
=={{header|Ada}}==
<lang ada>with Ada.Directories; use Ada.Directories;</lang>
<lang ada>
with Ada.Directories; use Ada.Directories;
</lang>
and then
<lang ada>Delete_File ("input.txt");
Delete_File ("input.txt");
Delete_File ("/input.txt");
Delete_Tree ("docs");
Delete_Tree ("/docs");</lang>
</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:(
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
FileDelete, \input.txt
FileRemoveDir, docs, 1
FileRemoveDir, \docs, 1</lang>
</lang>
 
=={{header|AWK}}==
Assuming we are ona Unix/Linux or at least Cygwin system:
<lang awk> system("rm input.txt");
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
<lang fortran> OPEN (UNIT=5, FILE="input.txt", STATUS="OLD") ! Current directory
CLOSE (UNIT=5, STATUS="DELETE")
OPEN (UNIT=5, FILE="/input.txt", STATUS="OLD") ! Root directory
CLOSE (UNIT=5, STATUS="DELETE")</lang>
=={{header|Haskell}}==
 
<lang haskell> import System.IO
import System.Directory
Line 175 ⟶ 167:
removeDirectory "docs"
removeFile "/output.txt"
removeDirectory "/docs"</lang>
 
=={{header|Io}}==
<lang io> Directory fileNamed("input.txt") remove
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>
erasefile "/input.txt
</logo>
 
=={{header|MAXScript}}==
Line 301 ⟶ 291:
=={{header|Ruby}}==
 
<lang ruby> File.delete("output.txt", "/output.txt")
#!/usr/bin/env ruby
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.
(File newNamed: '/input.txt') delete.
(Directory newNamed: 'docs') delete.
(Directory newNamed: '/docs') delete.</lang>
</lang>
 
=={{header|Smalltalk}}==
Line 350 ⟶ 337:
 
=={{header|UNIX Shell}}==
<lang bash> rm -rf docs
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
// 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>
</lang>
 
=={{header|Visual Basic .NET}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.