Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Js

Idiom #95 Get file size

Assign to variable x the length (number of bytes) of the local file at path.

const {readFileSync: read} = require ('fs')
let x = read(path).length

Only works with NodeJS (server-side JavaScript) because the browser isn't allowed to access your files.
with Ada.Directories; use Ada.Directories;
X : constant File_Size := Size (Path);

New implementation...
< >
programming-idioms.org