pub async fn async_get_file_size(file_path: &str) -> Option<u64>
Expand description
Retrieves the size of a file at the specified file_path
in bytes.
§Parameters
file_path
: The path to the file whose size is to be fetched.
§Returns
Option<u64>
:Some(size)
: The size of the file in bytes if the file exists and its metadata can be accessed.None
: If the file doesn’t exist, or there is an error retrieving the file’s metadata.
§Errors
- If the file at
file_path
doesn’t exist, or there is an issue accessing its metadata, the function will returnNone
to indicate the failure.
§Notes
- The function uses
metadata
to retrieve the file’s metadata and specifically its size (metadata.len()
). If the file metadata is not accessible or the file does not exist, the function will returnNone
. This is useful when you want to safely handle cases where the file might not be present or readable.