new files

This commit is contained in:
Ingy döt Net 2013-04-10 12:38:42 -07:00
parent 3af7344581
commit 86c034bb8b
1364 changed files with 21352 additions and 0 deletions

View file

@ -0,0 +1 @@
In this task, the job is to delete a file called "input.txt" and delete a directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.

View file

@ -0,0 +1,2 @@
---
note: File System Operations

View file

@ -0,0 +1,4 @@
system("rm input.txt");
system("rm /input.txt");
system("rm -rf docs");
system("rm -rf /docs");

View file

@ -0,0 +1 @@
with Ada.Directories; use Ada.Directories;

View file

@ -0,0 +1,4 @@
Delete_File ("input.txt");
Delete_File ("/input.txt");
Delete_Tree ("docs");
Delete_Tree ("/docs");

View file

@ -0,0 +1,4 @@
KILL "INPUT.TXT"
KILL "C:\INPUT.TXT"
SHELL "RMDIR /S /Q DIR"
SHELL "RMDIR /S /Q C:\DIR"

View file

@ -0,0 +1 @@
ERASE "m"; 1; "INPUTTXT"

View file

@ -0,0 +1,9 @@
#include <stdio.h>
int main() {
remove("input.txt");
remove("/input.txt");
remove("docs");
remove("/docs");
return 0;
}

View file

@ -0,0 +1,9 @@
#include <unistd.h>
int main() {
unlink("input.txt");
unlink("/input.txt");
rmdir("docs");
rmdir("/docs");
return 0;
}

View file

@ -0,0 +1,6 @@
(import '(java.io File))
(.delete (File. "output.txt"))
(.delete (File. "docs"))
(.delete (new File (str (File/separator) "output.txt")))
(.delete (new File (str (File/separator) "docs")))

View file

@ -0,0 +1 @@
file:delete("file.txt").

View file

@ -0,0 +1,2 @@
s" input.txt" delete-file throw
s" /input.txt" delete-file throw

View file

@ -0,0 +1,4 @@
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")

View file

@ -0,0 +1,12 @@
package main
import "os"
func main() {
os.Remove("input.txt")
os.Remove("/input.txt")
os.Remove("docs")
os.Remove("/docs")
// recursively removes contents:
os.RemoveAll("docs")
os.RemoveAll("/docs")
}

View file

@ -0,0 +1,8 @@
import System.IO
import System.Directory
main = do
removeFile "output.txt"
removeDirectory "docs"
removeFile "/output.txt"
removeDirectory "/docs"

View file

@ -0,0 +1,18 @@
import java.util.File;
public class FileDeleteTest {
public static boolean deleteFile(String filename) {
boolean exists = new File(filename).delete();
return exists;
}
public static void test(String type, String filename) {
System.out.println("The following " + type + " called " + filename +
(deleteFile(filename) ? " was deleted." : " could not be deleted.")
);
}
public static void main(String args[]) {
test("file", "input.txt");
test("file", File.seperator + "input.txt");
test("directory", "docs");
test("directory", File.seperator + "docs" + File.seperator);
}
}

View file

@ -0,0 +1,7 @@
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.DeleteFile('input.txt');
fso.DeleteFile('c:/input.txt');
fso.DeleteFolder('docs');
fso.DeleteFolder('c:/docs');

View file

@ -0,0 +1,10 @@
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f;
f = fso.GetFile('input.txt');
f.Delete();
f = fso.GetFile('c:/input.txt');
f.Delete();
f = fso.GetFolder('docs');
f.Delete();
f = fso.GetFolder('c:/docs');
f.Delete();

View file

@ -0,0 +1,4 @@
os.remove("input.txt")
os.remove("/input.txt")
os.remove("docs")
os.remove("/docs")

View file

@ -0,0 +1,6 @@
<?php
unlink('input.txt');
unlink('/input.txt');
rmdir('docs');
rmdir('/docs');
?>

View file

@ -0,0 +1,7 @@
use File::Spec::Functions qw(catfile rootdir);
# here
unlink 'input.txt';
rmdir 'docs';
# root dir
unlink catfile rootdir, 'input.txt';
rmdir catfile rootdir, 'docs';

View file

@ -0,0 +1,4 @@
(call 'rm "input.txt")
(call 'rmdir "docs")
(call 'rm "/input.txt")
(call 'rmdir "/docs")

View file

@ -0,0 +1,7 @@
import os
# current directory
os.remove("output.txt")
os.rmdir("docs")
# root directory
os.remove("/output.txt")
os.rmdir("/docs")

View file

@ -0,0 +1,2 @@
import shutil
shutil.rmtree("docs")

View file

@ -0,0 +1,12 @@
file.remove("input.txt")
file.remove("/input.txt")
# or
file.remove("input.txt", "/input.txt")
# or
unlink("input.txt"); unlink("/input.txt")
# directories needs the recursive flag
unlink("docs", recursive = TRUE)
unlink("/docs", recursive = TRUE)

View file

@ -0,0 +1,3 @@
File.delete("output.txt", "/output.txt")
Dir.delete("docs")
Dir.delete("/docs")

View file

@ -0,0 +1 @@
(delete-file filename)

View file

@ -0,0 +1,4 @@
File remove: 'input.txt'.
File remove: 'docs'.
File remove: '/input.txt'.
File remove: '/docs'

View file

@ -0,0 +1,7 @@
file delete input.txt /input.txt
# preserve directory if non-empty
file delete docs /docs
# delete even if non-empty
file delete -force docs /docs