/** * @contents The contents of the file to append * @metadata Struct of metadata to store with the file * @throwOnMissing Boolean flag to throw if the file is missing. Otherwise it will be created if missing. * * @return File * * @throws cbfs.FileNotFoundException */functionappend( required contents, struct metadata = {}, boolean throwOnMissing =false);
checksum
Generate checksum for a file in different hashing algorithms.
/** * Generate checksum for a file in different hashing algorithms * * @algorithm Default is MD5, but SHA-1, SHA-256, and SHA-512 can also be used. * * @throws cbfs.FileNotFoundException */string functionchecksum( algorithm ="MD5" );
chmod
Sets the access attributes of the file on Unix based disks.
/** * @mode Access mode, the same attributes you use for the Linux command `chmod` * @return File */functionchmod( required string mode );
copy
Copy a file from one destination to another.
/*** @destination The end destination path* @overwrite Flag to overwrite the file at the destination, if it exists. Defaults to true.** @return File - returns the copied file object** @throws cbfs.FileNotFoundException - When the source doesn't exist* @throws cbfs.FileOverrideException - When the destination exists and no override has been provided*/functioncopy( required destination, boolean overwrite =true);
create
Creates a file on the disk.
/** * @contents The contents of the file to store * @visibility The storage visibility of the file, available options are `public, private, readonly` or a custom data type the implemented driver can interpret * @metadata Struct of metadata to store with the file * @overwrite Flag to overwrite the file at the destination, if it exists. Defaults to true. * @mode Applies to *nix systems. If passed, it overrides the visbility argument and uses these octal values instead * * @return File * * @throws cbfs.FileOverrideException - When a file exists and no override has been provided */functioncreate( required contents, string visibility, struct metadata = {}, boolean overwrite =true, string mode);
delete
Delete a file or an array of file paths. If a file does not exist a false will be shown for its return.
/** * @throwOnMissing Boolean to throw an exception if the file is missing. * * @return boolean * * @throws cbfs.FileNotFoundException */boolean functiondelete( boolean throwOnMissing =false );
exists
Validate if a file exists.
/*** @path The file path to verify*/boolean functionexists();
extension
Extract the extension from the file path.
string functionextension();
get
Get the contents of a file.
/*** @return The contents of the file** @throws cbfs.FileNotFoundException*/any functionget();
info
Return information about the file. Will contain keys such as lastModified, size, path, name, type, canWrite, canRead, isHidden and more depending on the provider used.
/*** @return A struct of file metadata according to provider** @throws cbfs.FileNotFoundException*/struct functioninfo();
isExecutable
Returns true if the file is executable.
/*** @throws cbfs.FileNotFoundException - If the filepath is missing* * @return Boolean*/boolean functionisExecutable();
isHidden
Returns true if the file is hidden.
/*** @throws cbfs.FileNotFoundException - If the filepath is missing* * @return Boolean*/boolean functionisHidden();
/** * @destination The end destination path * * @return File - the moved file object * * @throws cbfs.FileNotFoundException - When the source doesn't exist * @throws cbfs.FileOverrideException - When the destination exists and no override has been provided */functionmove( required destination, boolean overwrite =true);
prepend
Prepend contents to the beginning of a file. This is a very expensive operation for local disk storage.
/*** @contents The contents of the file to prepend* @metadata Struct of metadata to store with the file* @throwOnMissing Boolean flag to throw if the file is missing. Otherwise it will be created if missing.** @return File** @throws cbfs.FileNotFoundException*/functionprepend( required contents, struct metadata = {}, boolean throwOnMissing =false);
setVisibility
Set the storage visibility of a file. Available options are public, private, readonly or a custom data type the implemented driver can interpret.
/*** @visibility The storage visibility of the file, available options are `public, private, readonly` or a custom data type the implemented driver can interpret** @return File*/functionsetVisibility( required string visibility );
size
Returns the size of a file (in bytes). The size may differ from the actual size on the file system due to compression, support for sparse files, or other reasons.
This is currently only available when working with a Local Provider disk.
Return a Java stream of the file using non-blocking IO classes. The stream will represent every line in the file so you can navigate through it. This method leverages the cbstreams library used accordingly by implementations (https://www.forgebox.io/view/cbstreams)
/** * @expiration The number of minutes this url should be valid for. Defaults to 60 minutes */string functiontemporaryUrl( numeric expiration =60 );
touch
Create a new empty file if it does not exist.
/*** @createPath if set to false, expects all parent directories to exist, true will generate necessary directories. Defaults to true.** @return File** @throws cbfs.PathNotFoundException*/functiontouch( boolean createPath =true );
Get the storage visibility of a file. The return format can be a string of public, private, readonly or a custom data type the implemented driver can interpret.