Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/Delete_a_file
note: File System Operations

View file

@ -0,0 +1,6 @@
;Task:
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.
<br><br>

View file

@ -0,0 +1,4 @@
fs:remove_file(output.txt)
fs:remove_dir(docs)
fs:remove_file(/output.txt)
fs:remove_dir(/docs)

View file

@ -0,0 +1,4 @@
"input.txt" f:rm drop
"/input.txt" f:rm drop
"docs" f:rmdir drop
"/docs" f:rmdir drop

View file

@ -0,0 +1,80 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program deleteFic64.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
.equ UNLINK, 35
.equ AT_REMOVEDIR, 0x200 // flag for delete directory
/******************************************/
/* Initialized data */
/******************************************/
.data
szMessDeleteDirOk: .asciz "Delete directory Ok.\n"
szMessErrDeleteDir: .asciz "Unable delete dir. \n"
szMessDeleteFileOk: .asciz "Delete file Ok.\n"
szMessErrDeleteFile: .asciz "Unable delete file. \n"
szNameDir: .asciz "Docs"
szNameFile: .asciz "input.txt"
/******************************************/
/* UnInitialized data */
/******************************************/
.bss
/******************************************/
/* code section */
/******************************************/
.text
.global main
main: // entry of program
// delete file
mov x0,AT_FDCWD // current directory
ldr x1,qAdrszNameFile // file name
mov x8,UNLINK // code call system delete file
svc 0 // call systeme
cmp x0,0 // error ?
blt 99f
ldr x0,qAdrszMessDeleteFileOk // delete file OK
bl affichageMess
// delete directory
mov x0,AT_FDCWD // current directory
ldr x1,qAdrszNameDir // directory name
mov x2,AT_REMOVEDIR
mov x8,UNLINK // code call system delete directory
svc 0 // call systeme
cmp x0,0 // error ?
blt 98f
ldr x0,qAdrszMessDeleteDirOk // display message ok directory
bl affichageMess
// end Ok
b 100f
98: // display error message delete directory
ldr x0,qAdrszMessErrDeleteDir
bl affichageMess
b 100f
99: // display error message delete file
ldr x0,qAdrszMessErrDeleteFile
bl affichageMess
b 100f
100: // standard end of the program
mov x0,0 // return code
mov x8,EXIT // request to exit program
svc 0 // perform the system call
qAdrszMessDeleteDirOk: .quad szMessDeleteDirOk
qAdrszMessErrDeleteDir: .quad szMessErrDeleteDir
qAdrszMessDeleteFileOk: .quad szMessDeleteFileOk
qAdrszNameFile: .quad szNameFile
qAdrszMessErrDeleteFile: .quad szMessErrDeleteFile
qAdrszNameDir: .quad szNameDir
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

View file

@ -0,0 +1,17 @@
main:(
PROC remove = (STRING file name)INT:
BEGIN
FILE actual file;
INT errno = open(actual file, file name, stand back channel);
IF errno NE 0 THEN stop remove FI;
scratch(actual file); # detach the book and burn it #
errno
EXIT
stop remove:
errno
END;
remove("input.txt");
remove("/input.txt");
remove("docs");
remove("/docs")
)

View file

@ -0,0 +1,78 @@
/* ARM assembly Raspberry PI */
/* program deleteFic.s */
/* REMARK 1 : this program use routines in a include file
see task Include a file language arm assembly
for the routine affichageMess conversion10
see at end of this program the instruction include */
/***************************************************************/
/* File Constantes see task Include a file for arm assembly */
/***************************************************************/
.include "../constantes.inc"
.equ RMDIR, 0x28
.equ UNLINK, 0xA
/******************************************/
/* Initialized data */
/******************************************/
.data
szMessDeleteDirOk: .asciz "Delete directory Ok.\n"
szMessErrDeleteDir: .asciz "Unable delete dir. \n"
szMessDeleteFileOk: .asciz "Delete file Ok.\n"
szMessErrDeleteFile: .asciz "Unable delete file. \n"
szNameDir: .asciz "Docs"
szNameFile: .asciz "input.txt"
/******************************************/
/* UnInitialized data */
/******************************************/
.bss
/******************************************/
/* code section */
/******************************************/
.text
.global main
main: @ entry of program
@ delete file
ldr r0,iAdrszNameFile @ file name
mov r7,#UNLINK @ code call system delete file
svc #0 @ call systeme
cmp r0,#0 @ error ?
blt 99f
ldr r0,iAdrszMessDeleteFileOk @ delete file OK
bl affichageMess
@ delete directory
ldr r0,iAdrszNameDir @ directory name
mov r7, #RMDIR @ code call system delete directory
swi #0 @ call systeme
cmp r0,#0 @ error ?
blt 98f
ldr r0,iAdrszMessDeleteDirOk @ display message ok directory
bl affichageMess
@ end Ok
b 100f
98: @ display error message delete directory
ldr r0,iAdrszMessErrDeleteDir
bl affichageMess
b 100f
99: @ display error message delete file
ldr r0,iAdrszMessErrDeleteFile
bl affichageMess
b 100f
100: @ standard end of the program
mov r0, #0 @ return code
mov r7, #EXIT @ request to exit program
swi 0 @ perform the system call
iAdrszMessDeleteDirOk: .int szMessDeleteDirOk
iAdrszMessErrDeleteDir: .int szMessErrDeleteDir
iAdrszMessDeleteFileOk: .int szMessDeleteFileOk
iAdrszNameFile: .int szNameFile
iAdrszMessErrDeleteFile: .int szMessErrDeleteFile
iAdrszNameDir: .int szNameDir
/***************************************************/
/* ROUTINES INCLUDE */
/***************************************************/
.include "../affichage.inc"

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,35 @@
PROC Dir(CHAR ARRAY filter)
CHAR ARRAY line(255)
BYTE dev=[1]
Close(dev)
Open(dev,filter,6)
DO
InputSD(dev,line)
PrintE(line)
IF line(0)=0 THEN
EXIT
FI
OD
Close(dev)
RETURN
PROC DeleteFile(CHAR ARRAY fname)
BYTE dev=[1]
Close(dev)
Xio(dev,0,33,0,0,fname)
RETURN
PROC Main()
CHAR ARRAY filter="D:*.*", fname="D:INPUT.TXT"
PrintF("Dir ""%S""%E",filter)
Dir(filter)
PrintF("Delete file ""%S""%E%E",fname)
DeleteFile(fname)
PrintF("Dir ""%S""%E",filter)
Dir(filter)
RETURN

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 @@
remove ("input.txt")
remove ("/input.txt")
remove ("docs")
remove ("/docs")

View file

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

View file

@ -0,0 +1 @@
0 PRINT CHR$ (4)"DELETE INPUT.TXT"

View file

@ -0,0 +1,8 @@
file: "input.txt"
docs: "docs"
delete file
delete.directory file
delete join.path ["/" file]
delete.directory join.path ["/" docs]

View file

@ -0,0 +1,4 @@
FileDelete, input.txt
FileDelete, \input.txt
FileRemoveDir, docs, 1
FileRemoveDir, \docs, 1

View file

@ -0,0 +1,6 @@
DeleteFile(lpFileName)
{
DllCall("Kernel32.dll\DeleteFile", "Str", lpFileName)
}
DeleteFile("C:\Temp\TestFile.txt")

View file

@ -0,0 +1 @@
DelVar "appvINPUT"

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,4 @@
*DELETE input.txt
*DELETE \input.txt
*RMDIR docs
*RMDIR \docs

View file

@ -0,0 +1,2 @@
OSCLI "DELETE " + file$
OSCLI "RMDIR " + dir$

View file

@ -0,0 +1,4 @@
•file.Remove "input.txt"
•file.Remove "/input.txt"
•file.RemoveDir "docs"
•file.RemoveDir "/docs"

View file

@ -0,0 +1,2 @@
DELETE FILE "input.txt"
DELETE FILE "/input.txt"

View file

@ -0,0 +1,5 @@
del input.txt
rd /s /q docs
del \input.txt
rd /s /q \docs

View file

@ -0,0 +1,13 @@
using System;
using System.IO;
namespace DeleteFile {
class Program {
static void Main() {
File.Delete("input.txt");
Directory.Delete("docs");
File.Delete("/input.txt");
Directory.Delete("/docs");
}
}
}

View file

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

View file

@ -0,0 +1,17 @@
using System;
using System.IO;
namespace RosettaCode {
class Program {
static void Main() {
try {
File.Delete("input.txt");
Directory.Delete("docs");
File.Delete(@"\input.txt");
Directory.Delete(@"\docs");
} catch (Exception exception) {
Console.WriteLine(exception.Message);
}
}
}
}

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,11 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Delete-Files.
PROCEDURE DIVISION.
CALL "CBL_DELETE_FILE" USING "input.txt"
CALL "CBL_DELETE_DIR" USING "docs"
CALL "CBL_DELETE_FILE" USING "/input.txt"
CALL "CBL_DELETE_DIR" USING "/docs"
GOBACK
.

View file

@ -0,0 +1,23 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Delete-Files-2.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT Local-File ASSIGN TO "input.txt".
SELECT Root-File ASSIGN TO "/input.txt".
DATA DIVISION.
FILE SECTION.
FD Local-File.
01 Local-Record PIC X.
FD Root-File.
01 Root-Record PIC X.
PROCEDURE DIVISION.
DELETE FILE Local-File
DELETE FILE Root-File
GOBACK
.

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,2 @@
(delete-file (make-pathname :name "input.txt"))
(delete-file (make-pathname :directory '(:absolute "") :name "input.txt"))

View file

@ -0,0 +1,5 @@
(let ((path (make-pathname :directory '(:relative "docs"))))
(ext:delete-dir path))
(let ((path (make-pathname :directory '(:absolute "docs"))))
(ext:delete-dir path))

View file

@ -0,0 +1,2 @@
(let ((path (make-pathname :directory '(:relative "docs"))))
(cl-fad:delete-directory-and-files path))

View file

@ -0,0 +1,8 @@
VAR
l: Files.Locator;
BEGIN
(* Locator is the directory *)
l := Files.dir.This("proof");
(* delete 'xx.txt' file, in directory 'proof' *)
Files.dir.Delete(l,"xx.txt");
END ...

View file

@ -0,0 +1,5 @@
import std.file: remove;
void main() {
remove("data.txt");
}

View file

@ -0,0 +1,8 @@
import tango.io.Path;
void main() {
remove("input.txt");
remove("/input.txt");
remove("docs");
remove("/docs");
}

View file

@ -0,0 +1,8 @@
import tango.stdc.posix.unistd;
void main() {
unlink("input.txt");
unlink("/input.txt");
rmdir("docs");
rmdir("/docs");
}

View file

@ -0,0 +1,12 @@
procedure TMain.btnDeleteClick(Sender: TObject);
var
CurrentDirectory : String;
begin
CurrentDirectory := GetCurrentDir;
DeleteFile(CurrentDirectory + '\input.txt');
RmDir(PChar(CurrentDirectory + '\docs'));
DeleteFile('c:\input.txt');
RmDir(PChar('c:\docs'));
end;

View file

@ -0,0 +1,4 @@
<file:input.txt>.delete(null)
<file:docs>.delete(null)
<file:///input.txt>.delete(null)
<file:///docs>.delete(null)

View file

@ -0,0 +1,12 @@
import system'io;
public program()
{
File.assign("output.txt").delete();
File.assign("\output.txt").delete();
Directory.assign("docs").delete();
Directory.assign("\docs").delete();
}

View file

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

View file

@ -0,0 +1,4 @@
(delete-file "input.txt")
(delete-directory "docs")
(delete-file "/input.txt")
(delete-directory "/docs")

View file

@ -0,0 +1,10 @@
-module(delete).
-export([main/0]).
main() ->
% current directory
ok = file:del_dir( "docs" ),
ok = file:delete( "input.txt" ),
% root directory
ok = file:del_dir( "/docs" ),
ok = file:delete( "/input.txt" ).

View file

@ -0,0 +1,10 @@
open System.IO
[<EntryPoint>]
let main argv =
let fileName = "input.txt"
let dirName = "docs"
for path in ["."; "/"] do
ignore (File.Delete(Path.Combine(path, fileName)))
ignore (Directory.Delete(Path.Combine(path, dirName)))
0

View file

@ -0,0 +1,2 @@
"docs" "/docs" [ delete-tree ] bi@
"input.txt" "/input.txt" [ delete-file ] bi@

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,8 @@
program DeleteFileExample
use kernel32
implicit none
print *, DeleteFile("input.txt")
print *, DeleteFile("\input.txt")
print *, RemoveDirectory("docs")
print *, RemoveDirectory("\docs")
end program

View file

@ -0,0 +1,18 @@
program deletion(input, output, stdErr);
const
rootDirectory = '/'; // might have to be altered for other platforms
inputTextFilename = 'input.txt';
docsFilename = 'docs';
var
fd: file;
begin
assign(fd, inputTextFilename);
erase(fd);
rmDir(docsFilename);
assign(fd, rootDirectory + inputTextFilename);
erase(fd);
rmDir(rootDirectory + docsFilename);
end.

View file

@ -0,0 +1,15 @@
' FB 1.05.0 Win64
' delete file and empty sub-directory in current directory
Kill "input.txt"
RmDir "docs"
' delete file and empty sub-directory in root directory c:\
' deleting file in root requires administrative privileges in Windows 10
'Kill "c:\input.txt"
'RmDir "c:\docs"
Print "Press any key to quit"
Sleep

View file

@ -0,0 +1,6 @@
###sysinclude dir.uh
// ===================
argc 3 < { #s ."Usage: " 0 argv print SPACE 1 argv print ." filename\n" end }
2 argv 'e !istrue { #s ."The given file ( " 2 argv print ." ) doesn't exist!\n" end }
2 argv removefile
end

View file

@ -0,0 +1,6 @@
###sysinclude dir.uh
#g argc 3 < { ."Usage: " #s 0 argv print SPACE 1 argv print SPACE ."unnecessary_directory\n" end }
2 argv 'd !istrue { ."The given directory doesn't exist! Exited.\n" }{
2 argv rmdir
}
end

View file

@ -0,0 +1,19 @@
include "NSLog.incl"
CFURLRef url
url = fn URLFileURLWithPath( fn StringByExpandingTildeInPath( @"~/Desktop/input.txt" ) )
if (fn FileManagerRemoveItemAtURL( url ) )
NSLog( @"File \"intput.txt\" deleted." )
else
NSLog( @"Unable to delete file \"input.txt\"." )
end if
url = fn URLFileURLWithPath( fn StringByExpandingTildeInPath( @"~/Desktop/docs" ) )
if (fn FileManagerRemoveItemAtURL( url ) )
NSLog( @"Directory \"docs\" deleted." )
else
NSLog( @"Unabled to delete directory \"docs\"." )
end if
HandleEvents

View file

@ -0,0 +1,5 @@
# Apparently GAP can only remove a file, not a directory
RemoveFile("input.txt");
# true
RemoveFile("docs");
# fail

View file

@ -0,0 +1,8 @@
Public Sub Main()
Kill User.home &/ "input.txt"
Rmdir User.home &/ "docs"
'Administrative privileges (sudo) would be required to mess about in Root - I'm not going there!
End

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,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()
}

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,7 @@
SYSTEM(DIR="docs") ! create docs in current directory (if not existent), make it current
OPEN (FILE="input.txt", "NEW") ! in current directory = docs
WRITE(FIle="input.txt", DELETE=1) ! no command to DELETE a DIRECTORY in HicEst
SYSTEM(DIR="C:\docs") ! create C:\docs (if not existent), make it current
OPEN (FILE="input.txt", "NEW") ! in current directory = C:\docs
WRITE(FIle="input.txt", DELETE=1)

View file

@ -0,0 +1,11 @@
100 WHEN EXCEPTION USE IOERROR
110 EXT "del input.txt"
120 EXT "del \input.txt"
130 EXT "rmdir docs"
140 EXT "rmdir \docs"
150 END WHEN
160 HANDLER IOERROR
170 PRINT "Error in line";EXLINE
180 PRINT "*** ";EXSTRING$(EXTYPE)
190 CONTINUE
200 END HANDLER

View file

@ -0,0 +1,4 @@
every dir := !["./","/"] do {
remove(f := dir || "input.txt") |stop("failure for file remove ",f)
rmdir(f := dir || "docs") |stop("failure for directory remove ",f)
}

View file

@ -0,0 +1,5 @@
Directory fileNamed("input.txt") remove
Directory directoryNamed("docs") remove
RootDir := Directory clone setPath("/")
RootDir fileNamed("input.txt") remove
RootDir directoryNamed("docs") remove

View file

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

View file

@ -0,0 +1,8 @@
load 'files'
ferase 'input.txt'
ferase '\input.txt'
ferase 'docs'
ferase '\docs'
NB. Or all at once...
ferase 'input.txt';'/input.txt';'docs';'/docs'

View file

@ -0,0 +1,4 @@
NB. =========================================================
NB.*ferase v erases a file
NB. Returns 1 if successful, otherwise _1
ferase=: (1!:55 :: _1:) @ (fboxname &>) @ boxopen

View file

@ -0,0 +1,4 @@
1!:55 <'input.txt'
1!:55 <'\input.txt'
1!:55 <'docs'
1!:55 <'\docs'

View file

@ -0,0 +1,21 @@
import java.io.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,2 @@
const fs = require('fs');
fs.unlinkSync('myfile.txt');

View file

@ -0,0 +1,4 @@
const fs = require('fs');
fs.unlink('myfile.txt', ()=>{
console.log("Done!");
})

View file

@ -0,0 +1,4 @@
"input.txt" fremove
"docs" fremove
"/input.txt" fremove
"/docs" fremove.

View file

@ -0,0 +1,5 @@
# Delete a file
rm("input.txt")
# Delete a directory
rm("docs", recursive = true)

View file

@ -0,0 +1,18 @@
// version 1.0.6
/* testing on Windows 10 which needs administrative privileges
to delete files from the root */
import java.io.File
fun main(args: Array<String>) {
val paths = arrayOf("input.txt", "docs", "c:\\input.txt", "c:\\docs")
var f: File
for (path in paths) {
f = File(path)
if (f.delete())
println("$path successfully deleted")
else
println("$path could not be deleted")
}
}

View file

@ -0,0 +1,19 @@
# Load the IO module
# Replace "<pathToIO.lm>" with the location where the io.lm Lang module was installed to without "<" and ">"
ln.loadModule(<pathToIO.lm>)
$file1 = [[io]]::fp.openFile(input.txt)
[[io]]::fp.delete($file1)
[[io]]::fp.closeFile($file1)
$file2 = [[io]]::fp.openFile(/input.txt)
[[io]]::fp.delete($file2)
[[io]]::fp.closeFile($file2)
$dir1 = [[io]]::fp.openFile(docs)
[[io]]::fp.delete($dir1)
[[io]]::fp.closeFile($dir1)
$dir2 = [[io]]::fp.openFile(/docs)
[[io]]::fp.delete($dir2)
[[io]]::fp.closeFile($dir2)

View file

@ -0,0 +1,17 @@
// delete file
local(f = file('input.txt'))
#f->delete
// delete directory
// directory must be empty before it can be successfully deleted. A failure is generated if the operation fails.
local(d = dir('docs'))
#d->delete
// delete file in root file system (requires permissions at user OS level)
local(f = file('//input.txt'))
#f->delete
// delete directory in root file system (requires permissions at user OS level)
// directory must be empty before it can be successfully deleted. A failure is generated if the operation fails.
local(d = file('//docs'))
#d->delete

View file

@ -0,0 +1,10 @@
' show where we are
print DefaultDir$
' in here
kill "input.txt"
result=rmdir("Docs")
' from root
kill "\input.txt"
result=rmdir("\Docs")

View file

@ -0,0 +1,4 @@
-- note: fileIO xtra is shipped with Director, i.e. an "internal"
fp = xtra("fileIO").new()
fp.openFile("input.txt", 0)
fp.delete()

View file

@ -0,0 +1,7 @@
-- note: fileIO xtra is shipped with Director, i.e. an "internal"
pd = the last char of _movie.path -- "\" for win, ":" for mac
_player.itemDelimiter = pd
vol = _movie.path.item[1]
fp = xtra("fileIO").new()
fp.openFile(vol&pd&"input.txt", 0)
fp.delete()

View file

@ -0,0 +1,8 @@
-- delete (empty) directory "docs" in cwd
bx_folder_delete("docs")
-- delete (empty) directory "docs" in root of current volume
pd = the last char of _movie.path -- "\" for win, ":" for mac
_player.itemDelimiter = pd
vol = _movie.path.item[1]
bx_folder_delete(vol&pd&"docs")

View file

@ -0,0 +1 @@
|era,"input.txt"

View file

@ -0,0 +1,2 @@
erasefile "input.txt
erasefile "/input.txt

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,4 @@
delete('input.txt'); % delete local file input.txt
delete('/input.txt'); % delete file /input.txt
rmdir('docs'); % remove local directory docs
rmdir('/docs'); % remove directory /docs

View file

@ -0,0 +1,12 @@
if system('rm input.txt') == 0
disp('input.txt removed')
end
if system('rm /input.txt') == 0
disp('/input.txt removed')
end
if system('rmdir docs') == 0
disp('docs removed')
end
if system('rmdir /docs') == 0
disp('/docs removed')
end

View file

@ -0,0 +1,4 @@
-- Here
deleteFile "input.txt"
-- Root
deleteFile "\input.txt"

View file

@ -0,0 +1,4 @@
FileTools:-Remove("input.txt");
FileTools:-RemoveDirectory("docs");
FileTools:-Remove("/input.txt");
FileTools:-RemoveDirectory("/docs");

View file

@ -0,0 +1,5 @@
wd = NotebookDirectory[];
DeleteFile[wd <> "input.txt"]
DeleteFile["/" <> "input.txt"]
DeleteDirectory[wd <> "docs"]
DeleteDirectory["/" <> "docs"]

View file

@ -0,0 +1,14 @@
:- module delete_file.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
io.remove_file("input.txt", _, !IO),
io.remove_file("/input.txt", _, !IO),
io.remove_file("docs", _, !IO),
io.remove_file("/docs", _, !IO).

View file

@ -0,0 +1,5 @@
f = new(Nanoquery.IO.File)
f.delete("input.txt")
f.delete("docs")
f.delete("/input.txt")
f.delete("/docs")

View file

@ -0,0 +1,20 @@
using System;
using System.IO;
using System.Console;
module DeleteFile
{
Main() : void
{
when (File.Exists("input.txt")) File.Delete("input.txt");
try {
when (File.Exists(@"\input.txt")) File.Delete(@"\input.txt");
}
catch {
|e is UnauthorizedAccessException => WriteLine(e.Message)
}
when (Directory.Exists("docs")) Directory.Delete("docs");
when (Directory.Exists(@"\docs")) Directory.Delete(@"\docs");
}
}

View file

@ -0,0 +1,35 @@
/* NetRexx */
options replace format comments java crossref symbols binary
runSample(arg)
return
-- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
method isFileDeleted(fn) public static returns boolean
ff = File(fn)
fDeleted = ff.delete()
return fDeleted
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg files
if files = '' then files = 'input.txt F docs D /input.txt F /docs D'
loop while files.length > 0
parse files fn ft files
select case(ft.upper())
when 'F' then do
ft = 'File'
end
when 'D' then do
ft = 'Directory'
end
otherwise do
ft = 'File'
end
end
if isFileDeleted(fn) then dl = 'deleted'
else dl = 'not deleted'
say ft ''''fn'''' dl
end
return

View file

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

View file

@ -0,0 +1,5 @@
import os
removeFile("input.txt")
removeFile("/input.txt")
removeDir("docs")
removeDir("/docs")

View file

@ -0,0 +1,4 @@
Sys.remove "input.txt";;
Sys.remove "/input.txt";;
Sys.rmdir "docs";;
Sys.rmdir "/docs";;

View file

@ -0,0 +1,5 @@
#load "unix.cma";;
Unix.unlink "input.txt";;
Unix.unlink "/input.txt";;
Unix.rmdir "docs";;
Unix.rmdir "/docs";;

View file

@ -0,0 +1,13 @@
use IO;
bundle Default {
class FileExample {
function : Main(args : String[]) ~ Nil {
File->Delete("output.txt");
File->Delete("/output.txt");
Directory->Delete("docs");
Directory->Delete("/docs");
}
}
}

View file

@ -0,0 +1,13 @@
NSFileManager *fm = [NSFileManager defaultManager];
// Pre-OS X 10.5
[fm removeFileAtPath:@"input.txt" handler:nil];
[fm removeFileAtPath:@"/input.txt" handler:nil];
[fm removeFileAtPath:@"docs" handler:nil];
[fm removeFileAtPath:@"/docs" handler:nil];
// OS X 10.5+
[fm removeItemAtPath:@"input.txt" error:NULL];
[fm removeItemAtPath:@"/input.txt" error:NULL];
[fm removeItemAtPath:@"docs" error:NULL];
[fm removeItemAtPath:@"/docs" error:NULL];

Some files were not shown because too many files have changed in this diff Show more