2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
8
Task/File-size/C++/file-size-2.cpp
Normal file
8
Task/File-size/C++/file-size-2.cpp
Normal 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";
|
||||
}
|
||||
9
Task/File-size/Elena/file-size.elena
Normal file
9
Task/File-size/Elena/file-size.elena
Normal 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).
|
||||
].
|
||||
12
Task/File-size/Fortran/file-size.f
Normal file
12
Task/File-size/Fortran/file-size.f
Normal 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...
|
||||
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
|
||||
1
Task/File-size/Maple/file-size-1.maple
Normal file
1
Task/File-size/Maple/file-size-1.maple
Normal file
|
|
@ -0,0 +1 @@
|
|||
FileTools:-Size( "input.txt" )
|
||||
1
Task/File-size/Maple/file-size-2.maple
Normal file
1
Task/File-size/Maple/file-size-2.maple
Normal file
|
|
@ -0,0 +1 @@
|
|||
FileTools:-Size( "/input.txt" )
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols binary
|
||||
options replace format comments java symbols binary
|
||||
|
||||
runSample(arg)
|
||||
return
|
||||
|
|
|
|||
1
Task/File-size/Perl-6/file-size-2.pl6
Normal file
1
Task/File-size/Perl-6/file-size-2.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
say $*SPEC.rootdir.IO.child("input.txt").s;
|
||||
2
Task/File-size/Perl/file-size-1.pl
Normal file
2
Task/File-size/Perl/file-size-1.pl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
my $size1 = -s 'input.txt';
|
||||
my $size2 = -s '/input.txt';
|
||||
3
Task/File-size/Perl/file-size-2.pl
Normal file
3
Task/File-size/Perl/file-size-2.pl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
use File::Spec::Functions qw(catfile rootdir);
|
||||
my $size1 = -s 'input.txt';
|
||||
my $size2 = -s catfile rootdir, 'input.txt';
|
||||
2
Task/File-size/Perl/file-size-3.pl
Normal file
2
Task/File-size/Perl/file-size-3.pl
Normal 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];
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
use File::Spec::Functions qw(catfile rootdir);
|
||||
print -s 'input.txt';
|
||||
print -s catfile rootdir, 'input.txt';
|
||||
|
|
@ -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 $
|
||||
|
|
|
|||
|
|
@ -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 $
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue