2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1 +1,2 @@
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.
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.
<br><br>

View file

@ -1,9 +1,11 @@
@load "filefuncs"
function filesize(name ,fd) {
if ( stat(name, fd) == -1)
return -1 # doesn't exist
else
return fd["size"]
}
BEGIN {
printsize("input.txt")
printsize("/input.txt")
}
function printsize(name ,fd) {
stat(name, fd)
printf("%s\t%s\n", name, fd["size"])
print filesize("input.txt")
print filesize("/input.txt")
}

View file

@ -0,0 +1,8 @@
#include <iostream>
#include <fstream>
int main()
{
std::cout << std::ifstream("input.txt", std::ios::binary | std::ios::ate).tellg() << "\n"
<< std::ifstream("/input.txt", std::ios::binary | std::ios::ate).tellg() << "\n";
}

View file

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

View file

@ -0,0 +1,12 @@
20 READ (INF,21, END = 30) L !R E A D A R E C O R D - but only its length.
21 FORMAT(Q) !This obviously indicates the record's length.
NRECS = NRECS + 1 !CALL LONGCOUNT(NRECS,1) !C O U N T A R E C O R D.
NNBYTES = NNBYTES + L !CALL LONGCOUNT(NNBYTES,L) !Not counting any CRLF (or whatever) gibberish.
IF (L.LT.RMIN) THEN !Righto, now for the record lengths.
RMIN = L !This one is shorter.
RMINR = NRECS !Where it's at.
ELSE IF (L.GT.RMAX) THEN !Perhaps instead it is longer?
RMAX = L !Longer.
RMAXR = NRECS !Where it's at.
END IF !So much for the lengths.
GO TO 20 !All I wanted to know...

View 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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
/* NetRexx */
options replace format comments java crossref symbols binary
options replace format comments java symbols binary
runSample(arg)
return

View file

@ -0,0 +1 @@
say $*SPEC.rootdir.IO.child("input.txt").s;

View file

@ -0,0 +1,2 @@
my $size1 = -s 'input.txt';
my $size2 = -s '/input.txt';

View file

@ -0,0 +1,3 @@
use File::Spec::Functions qw(catfile rootdir);
my $size1 = -s 'input.txt';
my $size2 = -s catfile rootdir, 'input.txt';

View file

@ -0,0 +1,2 @@
my $size1 = (stat 'input.txt')[7]; # builtin stat() returns an array with file size at index 7
my $size2 = (stat '/input.txt')[7];

View file

@ -1,3 +0,0 @@
use File::Spec::Functions qw(catfile rootdir);
print -s 'input.txt';
print -s catfile rootdir, 'input.txt';

View file

@ -1,12 +1,11 @@
/*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) 'bytes' /*current dir.*/
say 'size of \..\'iFID "=" filesize('\..\'iFID) 'bytes' /* root dir.*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────FILESIZE subroutine─────────────────*/
filesize: parse arg f; $=0; do while lines(f)\==0
$=$+length(charin(f,,1e6))
end /*while*/
return $
/*REXX program verifies a file's size (by reading all the lines) in current dir & root.*/
parse arg iFID . /*allow the user specify the file ID. */
if iFID=='' | iFID=="," then iFID='FILESIZ.DAT' /*Not specified? Then use the default.*/
say 'size of' iFID "=" fileSize(iFID) 'bytes' /*the current directory.*/
say 'size of \..\'iFID "=" fileSize('\..\'iFID) 'bytes' /* " root " */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
fileSize: parse arg f; $=0; do while lines(f)\==0
$=$+length(charin(f,,1e6))
end /*while*/
return $

View file

@ -1,11 +1,10 @@
/*REXX pgm to verify a file's size (by reading the lines) on default MD.*/
parse arg iFID /*let user specify the file ID. */
if iFID='' then iFID="FILESIZ DAT A" /*Not specified? Then use default*/
say 'size of' iFID "=" filesize(iFID) 'bytes' /*on the default MD.*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────FILESIZE subroutine─────────────────*/
filesize: parse arg f; $=0; do while lines(f)\==0
$=$+length(linein(f))
end /*while*/
return $
/*REXX program verifies a file's size (by reading all the lines) on the default mDisk.*/
parse arg iFID . /*allow the user specify the file ID. */
if iFID=='' | iFID=="," then iFID='FILESIZ DAT' /*Not specified? Then use the default.*/
say 'size of' iFID "=" filesize(iFID) 'bytes' /*on the default mDisk.*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
filesize: parse arg f; $=0; do while lines(f)\==0
$=$+length(linein(f))
end /*while*/
return $