From 9438f183b59f86ca09068fd31ccff0dbd6d832f5 Mon Sep 17 00:00:00 2001 From: Thibault Jeandet Date: Tue, 9 Feb 2016 16:17:24 -0500 Subject: [PATCH] Add a size function returning the size of a file --- SPEC.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/SPEC.md b/SPEC.md index 93d7598..f5d6cee 100644 --- a/SPEC.md +++ b/SPEC.md @@ -85,6 +85,7 @@ * [File write_object(Object)](#file-write_objectobject) * [File write_objects(Array\[Object\])](#file-write_objectsarrayobject) * [File write_json(mixed)](#file-write_jsonmixed) + * [File size(File, \[String\])](#float-sizefile-string) * [Data Types & Serialization](#data-types--serialization) * [Serialization of Task Inputs](#serialization-of-task-inputs) * [Primitive Types](#primitive-types) @@ -2090,6 +2091,28 @@ And `/local/fs/tmp/map.json` would contain: } ``` +## Float size(File, [String]) + +Given a `File` and a `String` (optional), returns the size of the file in Bytes or in the unit specified by the second argument. + +```wdl +task example { + File input_file + + command { + echo "this file is 22 bytes" > created_file + } + + output { + Float input_file_size = size(input_file) + Float created_file_size = size("created_file") # 22.0 + Float created_file_size_in_KB = size("created_file", "K") # 0.022 + } +} +``` + +Supported units are KiloByte ("K", "KB"), MegaByte ("M", "MB"), GigaByte ("G", "GB"), TeraByte ("T", "TB") as well as their [binary version](https://en.wikipedia.org/wiki/Binary_prefix) "Ki" ("KiB"), "Mi" ("MiB"), "Gi" ("GiB"), "Ti" ("TiB"). +Default unit is Bytes ("B"). # Data Types & Serialization