September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,12 @@
' file size
' Return the entire message, FILELEN returns a NUMBER
FUNCTION printlen$(STRING name$)
IF FILEEXISTS(name$) THEN
RETURN name$ & ": " & STR$(FILELEN(name$))
ELSE
RETURN "file " & name$ & " not found"
END IF
END FUNCTION
PRINT printlen$("input.txt")
PRINT printlen$("/input.txt")

View file

@ -1,5 +0,0 @@
import std.file;
void main() {
auto len = getSize("data.txt");
}

View file

@ -1,35 +0,0 @@
import std.stdio, std.path, std.file, std.stream;
// NB: mmfile can treat the file as an array in memory
import std.mmfile;
string[] generateTwoNames(string name) {
string cwd = curdir ~ sep; // on current directory
string root = sep; // on root
// remove path, left only basename
name = std.path.getBaseName(name);
// NB: in D ver.2, getBaseName is alias of basename
return [cwd ~ name, root ~ name];
}
void testsize(string fileName1) {
foreach (fileName2; generateTwoNames(fileName1)) {
try {
writefln("File %s has size:", fileName2);
writefln("%10d bytes by std.file.getSize (function),",
std.file.getSize(fileName2));
writefln("%10d bytes by std.stream (class),",
(new std.stream.File(fileName2)).size);
writefln("%10d bytes by std.mmfile (class).",
(new std.mmfile.MmFile(fileName2)).length);
} catch (Exception e) {
writefln(e.msg);
}
writeln();
}
}
void main() {
testsize(r"input.txt");
}

View file

@ -1,9 +1,9 @@
#import system.
#import system'io.
import system'io.
import extensions.
#symbol program =
program =
[
console writeLine:("input.txt" file_path length).
console printLine(File new:"input.txt"; length).
console writeLine:("\input.txt" file_path length).
console printLine(File new("\input.txt"); length).
].

View file

@ -0,0 +1,8 @@
Public Sub Main()
Dim stInfo As Stat = Stat(User.home &/ "input.txt")
Dim stInfo1 As Stat = Stat("/input.txt")
Print User.Home &/ "input.txt = " & stInfo.Size & " bytes"
Print "/input.txt = " & stInfo1.Size & " bytes"
End

View file

@ -0,0 +1,9 @@
// version 1.0.6
import java.io.File
fun main(args: Array<String>) {
val paths = arrayOf("input.txt", "c:\\input.txt")
for (path in paths)
println("Length of $path is ${File(path).length()} bytes")
}

View file

@ -1 +0,0 @@
FileTools:-Size( "input.txt" )

View file

@ -1 +0,0 @@
FileTools:-Size( "/input.txt" )

View file

@ -0,0 +1,2 @@
echo -ag $file(input.txt).size bytes
echo -ag $file(C:\input.txt).size bytes

View file

@ -0,0 +1,13 @@
Parse Version v
Say v
fid='test.txt'
x=sysfiletree(fid,a.)
Say a.0
Say a.1
Say left(copies('123456789.',10),length(a.1))
Parse Var a.1 20 size .
Say 'file size:' size
s=charin(fid,,1000)
Say length(s)
Say 'file' fid
'type' fid

View file

@ -0,0 +1,5 @@
file open f using input.txt, read binary
file seek f eof
file seek f query
display r(loc)
file close f

View file

@ -0,0 +1,2 @@
describe using test.dta
display r(N)*r(width)

View file

@ -0,0 +1,68 @@
; x86_64 linux nasm
section .data
localFileName: db "input.txt", 0
rootFileName: db "/initrd.img", 0
section .text
global _start
_start:
; open file in current dir
mov rax, 2
mov rdi, localFileName
xor rsi, rsi
mov rdx, 0
syscall
push rax
mov rdi, rax ; file descriptior
mov rsi, 0 ; offset
mov rdx, 2 ; whence
mov rax, 8 ; sys_lseek
syscall
; compare result to actual size
cmp rax, 11
jne fail
; close the file
pop rdi
mov rax, 3
syscall
; open file in root dir
mov rax, 2
mov rdi, rootFileName
xor rsi, rsi
mov rdx, 0
syscall
push rax
mov rdi, rax ; file descriptior
mov rsi, 0 ; offset
mov rdx, 2 ; whence
mov rax, 8 ; sys_lseek
syscall
; compare result to actual size
cmp rax, 37722243
jne fail
; close the file
pop rdi
mov rax, 3
syscall
; test successful
mov rax, 60
mov rdi, 0
syscall
; test failed
fail:
mov rax, 60
mov rdi, 1
syscall

View file

@ -0,0 +1,2 @@
File.info("input.txt").println();
File.info("/input.txt").println();