# get_file_size

Definition: | object filesize = get_file_size(string filename, bool asStringK=false, integer width=1)
Description: | Get the size of a file in bytes. filename: the name of the file to query. asStringK: when true, automatically invoke/return file_size_k(filesize,width). width: ignored when asStringK is false, else passed unaltered to "". Returns an atom, the file size, or the string result from file_size_k(), or -1 if filename is not found or a directory.
pwa/p2js: | Not supported.
Comments: | This function does not compute the total size for a directory, and returns -1 instead. You will also get -1 if a wildcard is passed that matches more than one file, see dir(). Both forwardslash ('/') and backslash ('\\') are handled for all platforms.
Auxillary function: | There is also a matching object res = set_file_size(string filename, atom size) function that, obviously enough, allows you to set a specific file size (padding or truncating as rqd), returning true when it succeeds without error, otherwise an error string - see builtins/pfile.e for the full set.
Example: |
    ?get_file_size("C:/Program Files (x86)/Phix/builtins/pfile.e")      -- prints eg 34550
    ?get_file_size("C:/Program Files (x86)/Phix/builtins/pfile.e",true) -- prints eg "33.74KB"
Implementation: | See builtins\pfile.e (an autoinclude) for details of the actual implementation.
See Also: | dir
Technicalia | For compatibility with Euphoria, file_length() is a simple alias of get_file_size(), and behaves identically. Note that in Euphoria file_length() returns 0 for directories, whereas in Phix it returns -1.