Node:size, Next:, Previous:href, Up:XPath functions



size

Usage: size(pathname [, unit])

This function returns the size of a source file. It does not work with directories. This function might be useful for generating text in Web pages to indicate to the reader how big a download file is.

If no unit is supplied, the function will automatically which units to show the file size. A string will be returned containing the file size with appropriate precision and the units (e.g. 10B, 12kB, 3.1kB, 1.4MB).

If a unit is supplied, it is used and a integer value is returned based on the rounded size in that unit. If the rounded size is too small, the value of 1 will be returned (unless the size is exactly zero bytes). Zero is only returned if the file is empty. The valid units are: B for bytes, kB for kilobytes, and MB for megabytes.