Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
18
Task/Delete-a-file/Groovy/delete-a-file.groovy
Normal file
18
Task/Delete-a-file/Groovy/delete-a-file.groovy
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Gets the first filesystem root. On most systems this will be / or c:\
|
||||
def fsRoot = File.listRoots().first()
|
||||
|
||||
// Create our list of files (including directories)
|
||||
def files = [
|
||||
new File("input.txt"),
|
||||
new File(fsRoot, "input.txt"),
|
||||
new File("docs"),
|
||||
new File(fsRoot, "docs")
|
||||
]
|
||||
|
||||
/*
|
||||
We use it.directory to determine whether each file is a regular file or directory. If it is a directory, we delete
|
||||
it with deleteDir(), otherwise we just use delete().
|
||||
*/
|
||||
files.each{
|
||||
it.directory ? it.deleteDir() : it.delete()
|
||||
}
|
||||
4
Task/Delete-a-file/Maple/delete-a-file.maple
Normal file
4
Task/Delete-a-file/Maple/delete-a-file.maple
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
FileTools:-Remove("input.txt");
|
||||
FileTools:-RemoveDirectory("docs");
|
||||
FileTools:-Remove("/input.txt");
|
||||
FileTools:-RemoveDirectory("/docs");
|
||||
4
Task/Delete-a-file/NewLISP/delete-a-file.newlisp
Normal file
4
Task/Delete-a-file/NewLISP/delete-a-file.newlisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(delete-file "input.txt")
|
||||
(delete-file "/input.txt")
|
||||
(remove-dir "docs")
|
||||
(remove-dir "/docs")
|
||||
|
|
@ -2,17 +2,14 @@ import java.util._
|
|||
import java.io.File
|
||||
|
||||
object FileDeleteTest extends App {
|
||||
|
||||
def deleteFile(filename: String) = {
|
||||
new File(filename).delete();
|
||||
}
|
||||
def deleteFile(filename: String) = { new File(filename).delete() }
|
||||
|
||||
def test(typ: String, filename: String) = {
|
||||
System.out.println("The following " + typ + " called " + filename +
|
||||
(if (deleteFile(filename)) " was deleted." else " could not be deleted."))
|
||||
}
|
||||
test("file", "input.txt");
|
||||
test("file", File.separatorChar + "input.txt");
|
||||
test("directory", "docs");
|
||||
test("directory", File.separatorChar + "docs" + File.separatorChar);
|
||||
test("file", "input.txt")
|
||||
test("file", File.separatorChar + "input.txt")
|
||||
test("directory", "docs")
|
||||
test("directory", File.separatorChar + "docs" + File.separatorChar)
|
||||
}
|
||||
|
|
|
|||
10
Task/Delete-a-file/Seed7/delete-a-file.seed7
Normal file
10
Task/Delete-a-file/Seed7/delete-a-file.seed7
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "osfiles.s7i";
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
removeFile("input.txt");
|
||||
removeFile("/input.txt");
|
||||
removeTree("docs");
|
||||
removeTree("/docs");
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue