Skip to content

TreeSize (recursive size)

ts
function TreeSize(path: string): respSize;

Calculates the total size (in bytes) of the file or directory specified by path, including all nested files and subdirectories, in the VFS. Returns a respSize object with the result.

ParameterTypeRequirementExplanation
pathstringrequiredPath to a file or directory to measure
Return typeDescription
respSizeContains the total size in bytes; use Ok() and Size() to check the result and retrieve the value

Example

ts
var result = vfs.TreeSize('/data/project');
if (result.Ok()) {
  Log('Total size: ' + result.Size() + ' bytes');
} else {
  Log('TreeSize failed: ' + result.ErrorMsg());
}