File size: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(5 intermediate revisions by 3 users not shown)
Line 1,216:
<syntaxhighlight lang="frink">println[newJava["java.io.File", "input.txt"].length[]]
println[newJava["java.io.File", "/input.txt"].length[]]</syntaxhighlight>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
local fn DoIt
CFURLRef desktopURL = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask )
CFURLRef url = fn URLByAppendingPathComponent( desktopURL, @"test_file.txt" )
CFDictionaryRef attributes = fn FileManagerAttributesOfItemAtURL( url )
printf @"%@", fn DictionaryObjectForKey( attributes, NSFileSize )
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
 
=={{header|Gambas}}==
Line 1,382 ⟶ 1,396:
<syntaxhighlight lang="lang">
# Load the IO module
# Replace "<pathToIO.lm>" with the location where the io.lm langLang module was installed to without "<" and ">"
ln.loadModule(<pathToIO.lm>)
 
Line 2,344 ⟶ 2,358:
Dim root As New IO.FileInfo("\input.txt")
Console.WriteLine(root.Length)</syntaxhighlight>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="Go">
import os
 
fn main() {
paths := ["input.txt", "./input.txt", "non_existing_file.txt"]
for path in paths {
if os.is_file(path) == true {println("The size of '${path}' is ${os.file_size(path)} bytes")}
else {println("Not found: ${path}")}
}
}
</syntaxhighlight>
 
{{out}}
<pre>
The size of 'input.txt' is 22 bytes
The size of './input.txt' is 22 bytes
Not found: non_existing_file.txt
</pre>
 
=={{header|Wren}}==
Line 2,349 ⟶ 2,383:
 
To check the size of a file in the root, just change "input.txt" to "/input.txt" in the following script.
<syntaxhighlight lang="ecmascriptwren">import "io" for File
 
var name = "input.txt"
9,476

edits