Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
2
Task/File-input-output/Nu/file-input-output.nu
Normal file
2
Task/File-input-output/Nu/file-input-output.nu
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let text = open "input.txt"
|
||||
$text | save "output.txt"
|
||||
|
|
@ -1,10 +1,4 @@
|
|||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
fn main() {
|
||||
let mut file = File::open("input.txt").unwrap();
|
||||
let mut data = Vec::new();
|
||||
file.read_to_end(&mut data).unwrap();
|
||||
let mut file = File::create("output.txt").unwrap();
|
||||
file.write_all(&data).unwrap();
|
||||
let contents = std::fs::read("input.txt").expect("error reading input.txt");
|
||||
std::fs::write("output.txt", contents).expect("error writing output.txt");
|
||||
}
|
||||
|
|
|
|||
37
Task/File-input-output/S-BASIC/file-input-output.basic
Normal file
37
Task/File-input-output/S-BASIC/file-input-output.basic
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
comment
|
||||
Preserve file channel #0 (the console) while declaring channels
|
||||
#2 and #3 as sequential-access ASCII files.
|
||||
end
|
||||
files d, sa, sa
|
||||
var s = string:255
|
||||
based errcode = integer
|
||||
base errcode at 103H
|
||||
|
||||
comment
|
||||
CP/M expects upper case file names, but S-BASIC does not
|
||||
automatically convert file name arguments to upper case, so we
|
||||
have to do that ourself.
|
||||
end
|
||||
create "OUTPUT.TXT"
|
||||
open #1,"INPUT.TXT"
|
||||
open #2,"OUTPUT.TXT"
|
||||
|
||||
comment
|
||||
S-BASIC allows alphanumeric line "numbers" (which are treated simply
|
||||
as labels) as the target of GOTO and GOSUB statements, but the first
|
||||
character must be a digit
|
||||
end
|
||||
on error goto 9done
|
||||
|
||||
rem - runtime error code 15 signals read past end of file
|
||||
while errcode <> 15 do
|
||||
begin
|
||||
input3 #1; s
|
||||
print #2; s
|
||||
end
|
||||
|
||||
9done
|
||||
close #1
|
||||
close #2
|
||||
|
||||
end
|
||||
25
Task/File-input-output/Uxntal/file-input-output.uxnatl
Normal file
25
Task/File-input-output/Uxntal/file-input-output.uxnatl
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|
||||
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
||||
|a0 @File1 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
||||
|b0 @File2 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
||||
|
||||
|0100
|
||||
;in-file .File1/name DEO2
|
||||
;out-file .File2/name DEO2
|
||||
|
||||
&loop
|
||||
#0100 .File1/length DEO2k POP
|
||||
;buffer .File1/read DEO2
|
||||
.File1/success DEI2
|
||||
|
||||
.File2/length DEO2k POP
|
||||
;buffer .File2/write DEO2
|
||||
|
||||
EQU2 ?&loop
|
||||
|
||||
#80 .System/state DEO
|
||||
BRK
|
||||
|
||||
@in-file "input.txt 00
|
||||
@out-file "output.txt 00
|
||||
@buffer $100
|
||||
|
|
@ -1,16 +1,22 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var in = try std.fs.cwd().openFile("input.txt", .{});
|
||||
defer in.close();
|
||||
var out = try std.fs.cwd().openFile("output.txt", .{ .mode = .write_only });
|
||||
defer out.close();
|
||||
var file_reader = in.reader();
|
||||
var file_writer = out.writer();
|
||||
var buf: [100]u8 = undefined;
|
||||
var read: usize = 1;
|
||||
while (read > 0) {
|
||||
read = try file_reader.readAll(&buf);
|
||||
try file_writer.writeAll(buf[0..read]);
|
||||
}
|
||||
pub fn main() (error{OutOfMemory} || std.fs.File.OpenError || std.fs.File.ReadError || std.fs.File.WriteError)!void {
|
||||
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};
|
||||
defer _ = gpa.deinit();
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
const cwd = std.fs.cwd();
|
||||
|
||||
var input_file = try cwd.openFile("input.txt", .{ .mode = .read_only });
|
||||
defer input_file.close();
|
||||
|
||||
var output_file = try cwd.createFile("output.txt", .{});
|
||||
defer output_file.close();
|
||||
|
||||
// Restrict input_file's size to "up to 10 MiB".
|
||||
var input_file_content = try input_file.readToEndAlloc(allocator, 10 * 1024 * 1024);
|
||||
defer allocator.free(input_file_content);
|
||||
|
||||
try output_file.writeAll(input_file_content);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue