With which programming language would you implement a program that asks a file path from the user and prints out the size of it to the user?
With which programming language would you implement a program that asks a file path from the user and prints out the...
If it was me I would use C, no doubt a Python script would be easier, but meh.
Bash
Trolling the librtards by writing in a shitty scripting language.
require('readline').createInterface({input: process.stdin,output: process.stdout}).question('filename: ', function(f) { console.log(require('fs').statSync(f).size + ' bytes'); process.exit(); } );
I did some babby's first file handling in C# yesterday for renaming a shit ton of files. It's not too difficult to get access to a lot of info on directories and files.
PowerShell.
`stat`
`ls -l`
I wouldn't re-implement something that already exists so nothing. If my system doesn't have `ls` or a `stat` equivalent then i'm already fucked because implementing stat is above my head.
this
Autohotkey. It's like 2 lines of code, save as .ahk and double-click to run.
Just to prove it, this gives a full GUI with folder selection:
FileSelectFolder, WhichFolder
Loop, %WhichFolder%\*.*, , 1
FolderSize += %A_LoopFileSize%
MsgBox Size of %WhichFolder% is %FolderSize% bytes.
Save as whatever.ahk and double-click, done.
Bash or python.
Erlang
filepath = input("I ask a file path from you, the user. Write it here: ");
print("Okay, now I print the size of it, here goes: {}".format(len(filepath)))
C, all other languages would absolutely bloated, slow and utterly wasteful.
The only correct answer.
Bash
this tbqh
what the fuck? I meant the size of the file itself, not the path!
For something simple as this C is plenty
Well that's not what your wrote, brainlet. Learn English
node js
okay show us how
Based aspie
Assembly with windows dlls.
I would use the programming language called "ls".
bash
sh
read i && du $i | cut -f 1
Why not make it a function so autocomplete works?
Same reason why I did not check if the file actually exists. Because I am lazy