A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
1
Task/File-size/0DESCRIPTION
Normal file
1
Task/File-size/0DESCRIPTION
Normal file
|
|
@ -0,0 +1 @@
|
|||
In this task, the job is to verify the size of a file called "input.txt" for a file in the current working directory and another one in the file system root.
|
||||
2
Task/File-size/1META.yaml
Normal file
2
Task/File-size/1META.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
note: File System Operations
|
||||
1
Task/File-size/ALGOL-68/file-size.alg
Normal file
1
Task/File-size/ALGOL-68/file-size.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
PROC set = (REF FILE file, INT page, line, character)VOID: ~
|
||||
8
Task/File-size/Ada/file-size.ada
Normal file
8
Task/File-size/Ada/file-size.ada
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
with Ada.Directories; use Ada.Directories;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Test_File_Size is
|
||||
begin
|
||||
Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
|
||||
Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
|
||||
end Test_File_Size;
|
||||
4
Task/File-size/AutoHotkey/file-size.ahk
Normal file
4
Task/File-size/AutoHotkey/file-size.ahk
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
FileGetSize, FileSize, input.txt ; Retrieve the size in bytes.
|
||||
MsgBox, Size of input.txt is %FileSize% bytes
|
||||
FileGetSize, FileSize, \input.txt, K ; Retrieve the size in Kbytes.
|
||||
MsgBox, Size of \input.txt is %FileSize% Kbytes
|
||||
11
Task/File-size/BBC-BASIC/file-size.bbc
Normal file
11
Task/File-size/BBC-BASIC/file-size.bbc
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
file% = OPENIN(@dir$+"input.txt")
|
||||
IF file% THEN
|
||||
PRINT "File size = " ; EXT#file%
|
||||
CLOSE #file%
|
||||
ENDIF
|
||||
|
||||
file% = OPENIN("\input.txt")
|
||||
IF file% THEN
|
||||
PRINT "File size = " ; EXT#file%
|
||||
CLOSE #file%
|
||||
ENDIF
|
||||
14
Task/File-size/Bracmat/file-size.bracmat
Normal file
14
Task/File-size/Bracmat/file-size.bracmat
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(getFileSize=
|
||||
size
|
||||
. fil$(!arg,rb) {read in binary mode}
|
||||
& fil$(,END) {seek to end of file}
|
||||
& fil$(,TEL):?size {tell where we are}
|
||||
& fil$(,SET,-1) {seeking to an impossible position closes the file, and fails}
|
||||
| !size {return the size}
|
||||
);
|
||||
|
||||
getFileSize$"valid.bra"
|
||||
113622
|
||||
|
||||
getFileSize$"c:\\boot.ini"
|
||||
211
|
||||
16
Task/File-size/C++/file-size.cpp
Normal file
16
Task/File-size/C++/file-size.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
std::ios::off_type getFileSize(const char *filename) {
|
||||
std::ifstream f(filename);
|
||||
std::ios::pos_type begin = f.tellg();
|
||||
f.seekg(0, std::ios::end);
|
||||
std::ios::pos_type end = f.tellg();
|
||||
return end - begin;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << getFileSize("input.txt") << std::endl;
|
||||
std::cout << getFileSize("/input.txt") << std::endl;
|
||||
return 0;
|
||||
}
|
||||
19
Task/File-size/C/file-size-1.c
Normal file
19
Task/File-size/C/file-size-1.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
long getFileSize(const char *filename)
|
||||
{
|
||||
long result;
|
||||
FILE *fh = fopen(filename, "rb");
|
||||
fseek(fh, 0, SEEK_END);
|
||||
result = ftell(fh);
|
||||
fclose(fh);
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("%ld\n", getFileSize("input.txt"));
|
||||
printf("%ld\n", getFileSize("/input.txt"));
|
||||
return 0;
|
||||
}
|
||||
13
Task/File-size/C/file-size-2.c
Normal file
13
Task/File-size/C/file-size-2.c
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct stat foo;
|
||||
stat("input.txt", &foo);
|
||||
printf("%ld\n", foo.st_size);
|
||||
stat("/input.txt", &foo);
|
||||
printf("%ld\n", foo.st_size);
|
||||
return 0;
|
||||
}
|
||||
12
Task/File-size/Clean/file-size.clean
Normal file
12
Task/File-size/Clean/file-size.clean
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import StdEnv
|
||||
|
||||
fileSize fileName world
|
||||
# (ok, file, world) = fopen fileName FReadData world
|
||||
| not ok = abort "Cannot open file"
|
||||
# (ok, file) = fseek file 0 FSeekEnd
|
||||
| not ok = abort "Cannot seek file"
|
||||
# (size, file) = fposition file
|
||||
(_, world) = fclose file world
|
||||
= (size, world)
|
||||
|
||||
Start world = fileSize "input.txt" world
|
||||
6
Task/File-size/Clojure/file-size.clj
Normal file
6
Task/File-size/Clojure/file-size.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(import '[java.io File])
|
||||
(defn show-size [filename]
|
||||
(println filename "size:" (.length (File. filename))))
|
||||
|
||||
(show-size "input.txt")
|
||||
(show-size "/input.txt")
|
||||
9
Task/File-size/ColdFusion/file-size.cfm
Normal file
9
Task/File-size/ColdFusion/file-size.cfm
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<cfscript>
|
||||
localFile = getFileInfo(expandpath("input.txt"));
|
||||
rootFile = getFileInfo("/input.txt");
|
||||
</cfscript>
|
||||
|
||||
<cfoutput>
|
||||
Size of input.txt is #localFile.size# bytes.
|
||||
Size of /input.txt is #rootFile.size# bytes.
|
||||
</cfoutput>
|
||||
9
Task/File-size/Common-Lisp/file-size.lisp
Normal file
9
Task/File-size/Common-Lisp/file-size.lisp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(with-open-file (stream (make-pathname :name "input.txt")
|
||||
:direction :input
|
||||
:if-does-not-exist nil)
|
||||
(print (if stream (file-length stream) 0)))
|
||||
|
||||
(with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt")
|
||||
:direction :input
|
||||
:if-does-not-exist nil)
|
||||
(print (if stream (file-length stream) 0)))
|
||||
5
Task/File-size/D/file-size-1.d
Normal file
5
Task/File-size/D/file-size-1.d
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import std.file;
|
||||
|
||||
void main() {
|
||||
auto len = getSize("data.txt");
|
||||
}
|
||||
35
Task/File-size/D/file-size-2.d
Normal file
35
Task/File-size/D/file-size-2.d
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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");
|
||||
}
|
||||
21
Task/File-size/Delphi/file-size.delphi
Normal file
21
Task/File-size/Delphi/file-size.delphi
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
program SizeOfFile;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses SysUtils;
|
||||
|
||||
function CheckFileSize(const aFilename: string): Integer;
|
||||
var
|
||||
lFile: file of Byte;
|
||||
begin
|
||||
AssignFile(lFile, aFilename);
|
||||
FileMode := 0; {Access file in read only mode}
|
||||
Reset(lFile);
|
||||
Result := FileSize(lFile);
|
||||
CloseFile(lFile);
|
||||
end;
|
||||
|
||||
begin
|
||||
Writeln('input.txt ', CheckFileSize('input.txt'));
|
||||
Writeln('\input.txt ', CheckFileSize('\input.txt'));
|
||||
end.
|
||||
3
Task/File-size/E/file-size.e
Normal file
3
Task/File-size/E/file-size.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for file in [<file:input.txt>, <file:///input.txt>] {
|
||||
println(`The size of $file is ${file.length()} bytes.`)
|
||||
}
|
||||
21
Task/File-size/Eiffel/file-size.e
Normal file
21
Task/File-size/Eiffel/file-size.e
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
class
|
||||
APPLICATION
|
||||
create
|
||||
make
|
||||
feature {NONE} -- Initialization
|
||||
make
|
||||
-- Run application.
|
||||
do
|
||||
create input_file.make_open_read ("input.txt")
|
||||
print(input_file.count)
|
||||
print("%N")
|
||||
input_file.close
|
||||
create environment
|
||||
input_file.make_open_read(environment.root_directory_name + "input.txt")
|
||||
print(input_file.count)
|
||||
input_file.close
|
||||
end
|
||||
feature -- Access
|
||||
input_file: PLAIN_TEXT_FILE
|
||||
environment:EXECUTION_ENVIRONMENT
|
||||
end
|
||||
16
Task/File-size/Erlang/file-size.erl
Normal file
16
Task/File-size/Erlang/file-size.erl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-module(file_size).
|
||||
-export([file_size/0]).
|
||||
|
||||
-include_lib("kernel/include/file.hrl").
|
||||
|
||||
file_size() ->
|
||||
print_file_size("input.txt"),
|
||||
print_file_size("/input.txt").
|
||||
|
||||
print_file_size(Filename) ->
|
||||
case file:read_file_info(Filename) of
|
||||
{ok, FileInfo} ->
|
||||
io:format("~s ~p~n", [Filename, FileInfo#file_info.size]);
|
||||
{error, _} ->
|
||||
io:format("~s could not be opened~n",[Filename])
|
||||
end.
|
||||
24
Task/File-size/Euphoria/file-size.euphoria
Normal file
24
Task/File-size/Euphoria/file-size.euphoria
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
include file.e
|
||||
|
||||
function file_size(sequence file_name)
|
||||
object x
|
||||
x = dir(file_name)
|
||||
if sequence(x) and length(x) = 1 then
|
||||
return x[1][D_SIZE]
|
||||
else
|
||||
return -1 -- the file does not exist
|
||||
end if
|
||||
end function
|
||||
|
||||
procedure test(sequence file_name)
|
||||
integer size
|
||||
size = file_size(file_name)
|
||||
if size < 0 then
|
||||
printf(1,"%s file does not exist.\n",{file_name})
|
||||
else
|
||||
printf(1,"%s size is %d.\n",{file_name,size})
|
||||
end if
|
||||
end procedure
|
||||
|
||||
test("input.txt") -- in the current working directory
|
||||
test("/input.txt") -- in the file system root
|
||||
4
Task/File-size/Factor/file-size.factor
Normal file
4
Task/File-size/Factor/file-size.factor
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
"input.txt" file-info size>> .
|
||||
1321
|
||||
"file-does-not-exist.txt" file-info size>>
|
||||
"Unix system call ``stat'' failed:"...
|
||||
7
Task/File-size/Forth/file-size.fth
Normal file
7
Task/File-size/Forth/file-size.fth
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
: .filesize ( addr len -- ) 2dup type ." is "
|
||||
r/o open-file throw
|
||||
dup file-size throw <# #s #> type ." bytes long." cr
|
||||
close-file throw ;
|
||||
|
||||
s" input.txt" .filesize
|
||||
s" /input.txt" .filesize
|
||||
17
Task/File-size/Go/file-size.go
Normal file
17
Task/File-size/Go/file-size.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import "os"
|
||||
|
||||
func printFileSize(f string) {
|
||||
if stat, err := os.Stat(f); err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println(stat.Size())
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
printFileSize("input.txt")
|
||||
printFileSize("/input.txt")
|
||||
}
|
||||
2
Task/File-size/Groovy/file-size.groovy
Normal file
2
Task/File-size/Groovy/file-size.groovy
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
println new File('index.txt').length();
|
||||
println new File('/index.txt').length();
|
||||
5
Task/File-size/Haskell/file-size-1.hs
Normal file
5
Task/File-size/Haskell/file-size-1.hs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import System.IO
|
||||
|
||||
printFileSize filename = withFile filename ReadMode hFileSize >>= print
|
||||
|
||||
main = mapM_ printFileSize ["input.txt", "/input.txt"]
|
||||
6
Task/File-size/Haskell/file-size-2.hs
Normal file
6
Task/File-size/Haskell/file-size-2.hs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import System.Posix.File
|
||||
|
||||
printFileSize filename = do stat <- getFileStatus filename
|
||||
print (fileSize stat)
|
||||
|
||||
main = mapM_ printFileSize ["input.txt", "/input.txt"]
|
||||
2
Task/File-size/HicEst/file-size.hicest
Normal file
2
Task/File-size/HicEst/file-size.hicest
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
READ(FILE="input.txt", LENgth=bytes) ! bytes = -1 if not existent
|
||||
READ(FILE="C:\input.txt", LENgth=bytes) ! bytes = -1 if not existent
|
||||
3
Task/File-size/Icon/file-size.icon
Normal file
3
Task/File-size/Icon/file-size.icon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
every dir := !["./","/"] do {
|
||||
write("Size of ",f := dir || "input.txt"," = ",stat(f).size) |stop("failure for to stat ",f)
|
||||
}
|
||||
2
Task/File-size/J/file-size.j
Normal file
2
Task/File-size/J/file-size.j
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
require 'files'
|
||||
fsize 'input.txt';'/input.txt'
|
||||
10
Task/File-size/Java/file-size.java
Normal file
10
Task/File-size/Java/file-size.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import java.io.File;
|
||||
|
||||
public class FileSize
|
||||
{
|
||||
public static void main ( String[] args )
|
||||
{
|
||||
System.out.println("input.txt : " + new File("input.txt").length() + " bytes");
|
||||
System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes");
|
||||
}
|
||||
}
|
||||
3
Task/File-size/JavaScript/file-size-1.js
Normal file
3
Task/File-size/JavaScript/file-size-1.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
fso.GetFile('input.txt').Size;
|
||||
fso.GetFile('c:/input.txt').Size;
|
||||
14
Task/File-size/JavaScript/file-size-2.js
Normal file
14
Task/File-size/JavaScript/file-size-2.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
var file = document.getElementById("fileInput").files.item(0); //a file input element
|
||||
if (file) {
|
||||
var reader = new FileReader();
|
||||
reader.readAsText(file, "UTF-8");
|
||||
reader.onload = loadedFile;
|
||||
reader.onerror = errorHandler;
|
||||
}
|
||||
function loadedFile(event) {
|
||||
var fileString = event.target.result;
|
||||
alert(fileString.length);
|
||||
}
|
||||
function errorHandler(event) {
|
||||
alert(event);
|
||||
}
|
||||
2
Task/File-size/K/file-size.k
Normal file
2
Task/File-size/K/file-size.k
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
_size "input.txt"
|
||||
_size "/input.txt"
|
||||
9
Task/File-size/Liberty-BASIC/file-size.liberty
Normal file
9
Task/File-size/Liberty-BASIC/file-size.liberty
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
'input.txt in current directory
|
||||
OPEN DefaultDir$ + "/input.txt" FOR input AS #m
|
||||
PRINT "File size: "; lof(#m)
|
||||
CLOSE #m
|
||||
|
||||
'input.txt in root
|
||||
OPEN "c:/input.txt" FOR input AS #m
|
||||
PRINT "File size: "; lof(#m)
|
||||
CLOSE #m
|
||||
9
Task/File-size/Lua/file-size.lua
Normal file
9
Task/File-size/Lua/file-size.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function GetFileSize( filename )
|
||||
local fp = io.open( filename )
|
||||
if fp == nil then
|
||||
return nil
|
||||
end
|
||||
local filesize = fp:seek( "end" )
|
||||
fp:close()
|
||||
return filesize
|
||||
end
|
||||
4
Task/File-size/MATLAB/file-size.m
Normal file
4
Task/File-size/MATLAB/file-size.m
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
d1 = dir('input.txt');
|
||||
d2 = dir('/input.txt');
|
||||
fprintf('Size of input.txt is %d bytes\n', d1.bytes)
|
||||
fprintf('Size of /input.txt is %d bytes\n', d2.bytes)
|
||||
3
Task/File-size/MAXScript/file-size.max
Normal file
3
Task/File-size/MAXScript/file-size.max
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- Returns filesize in bytes or 0 if the file is missing
|
||||
getFileSize "index.txt"
|
||||
getFileSize "\index.txt"
|
||||
2
Task/File-size/Mathematica/file-size.mathematica
Normal file
2
Task/File-size/Mathematica/file-size.mathematica
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
FileByteCount["input.txt"]
|
||||
FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
|
||||
4
Task/File-size/Mirah/file-size.mirah
Normal file
4
Task/File-size/Mirah/file-size.mirah
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import java.io.File
|
||||
|
||||
puts File.new('file-size.mirah').length()
|
||||
puts File.new("./#{File.separator}file-size.mirah").length()
|
||||
16
Task/File-size/Modula-3/file-size.mod3
Normal file
16
Task/File-size/Modula-3/file-size.mod3
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
MODULE FSize EXPORTS Main;
|
||||
|
||||
IMPORT IO, Fmt, FS, File, OSError;
|
||||
|
||||
VAR fstat: File.Status;
|
||||
|
||||
BEGIN
|
||||
TRY
|
||||
fstat := FS.Status("input.txt");
|
||||
IO.Put("Size of input.txt: " & Fmt.LongInt(fstat.size) & "\n");
|
||||
fstat := FS.Status("/input.txt");
|
||||
IO.Put("Size of /input.txt: " & Fmt.LongInt(fstat.size) & "\n");
|
||||
EXCEPT
|
||||
| OSError.E => IO.Put("ERROR: Could not get file status.\n");
|
||||
END;
|
||||
END FSize.
|
||||
4
Task/File-size/PHP/file-size.php
Normal file
4
Task/File-size/PHP/file-size.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
echo filesize('input.txt'), "\n";
|
||||
echo filesize('/input.txt'), "\n";
|
||||
?>
|
||||
3
Task/File-size/Perl/file-size.pl
Normal file
3
Task/File-size/Perl/file-size.pl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
use File::Spec::Functions qw(catfile rootdir);
|
||||
print -s 'input.txt';
|
||||
print -s catfile rootdir, 'input.txt';
|
||||
2
Task/File-size/PicoLisp/file-size.l
Normal file
2
Task/File-size/PicoLisp/file-size.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(println (car (info "input.txt")))
|
||||
(println (car (info "/input.txt")))
|
||||
4
Task/File-size/Python/file-size.py
Normal file
4
Task/File-size/Python/file-size.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import os
|
||||
|
||||
size = os.path.getsize('input.txt')
|
||||
size = os.path.getsize('/input.txt')
|
||||
2
Task/File-size/R/file-size.r
Normal file
2
Task/File-size/R/file-size.r
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
sizeinwd <- file.info('input.txt')[["size"]]
|
||||
sizeinroot <- file.info('/input.txt')[["size"]]
|
||||
13
Task/File-size/REXX/file-size.rexx
Normal file
13
Task/File-size/REXX/file-size.rexx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*REXX pgm to verify a file's size (by reading the lines) in CD & root. */
|
||||
parse arg iFID . /*let user specify the file ID. */
|
||||
if iFID=='' then iFID='FILESIZ.DAT' /*Not specified? Then use default*/
|
||||
say 'size of' iFID '=' filesize(iFID) /*current directory.*/
|
||||
say 'size of \..\'iFID '=' filesize('\..\'iFID) /* root directory.*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
|
||||
/*──────────────────────────────────FILESIZE subroutine─────────────────*/
|
||||
filesize: parse arg f
|
||||
do r=1 while lines(f)\==0
|
||||
call linein f
|
||||
end /*r*/
|
||||
return r-1
|
||||
2
Task/File-size/Ruby/file-size.rb
Normal file
2
Task/File-size/Ruby/file-size.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
size = File.size('input.txt')
|
||||
size = File.size('/input.txt')
|
||||
10
Task/File-size/Scheme/file-size.ss
Normal file
10
Task/File-size/Scheme/file-size.ss
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(define (file-size filename)
|
||||
(call-with-input-file filename (lambda (port)
|
||||
(let loop ((c (read-char port))
|
||||
(count 0))
|
||||
(if (eof-object? c)
|
||||
count
|
||||
(loop (read-char port) (+ 1 count)))))))
|
||||
|
||||
(file-size "input.txt")
|
||||
(file-size "/input.txt")
|
||||
2
Task/File-size/Smalltalk/file-size-1.st
Normal file
2
Task/File-size/Smalltalk/file-size-1.st
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(File name: 'input.txt') size printNl.
|
||||
(File name: '/input.txt') size printNl.
|
||||
2
Task/File-size/Smalltalk/file-size-2.st
Normal file
2
Task/File-size/Smalltalk/file-size-2.st
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
'input.txt' asFilename fileSize
|
||||
'/input.txt' asFilename fileSize
|
||||
2
Task/File-size/Tcl/file-size.tcl
Normal file
2
Task/File-size/Tcl/file-size.tcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
file size input.txt
|
||||
file size /input.txt
|
||||
Loading…
Add table
Add a link
Reference in a new issue