Limes
4.8.1
C++ utilities and building blocks
|
Limes ships several small command-line utility programs, both as part of the testing process of the Limes libraries, but also because these utility programs can be genuinely useful.
Limes ships the following programs:
Name | Description |
---|---|
FileUtil | OS-agnostic interface for a wide variety of filesystem tasks |
BinaryBuilder | Generates C++ source files which embed binary data files |
When building the Limes programs in a crosscompiling scenario, they usually need to be executed on the host system, not the target system.
Because of this, when crosscompiling, a child CMake is invoked at configure time to execute the build of the programs for the host system, so that their artefacts are then available to the configuration for the target system.
BinaryBuilder
is a small command-line program that generates C++ source code that embeds some external data read from input files. The output files use the Limes binaries::FileInfo
and binaries::FileInfoList
interface for easy access of your embedded data at runtime.
All arguments are optional, except the <inputFiles> .
Prints usage and help messages.
The directory where the output files will be written to. No matter how many input files you pass, a single .cpp and
.h file will be generated, containing all the data. These files will be at
<outputDirectory>/<fileBaseName>.h and
<outputDirectory>/<fileBaseName>.cpp .
<outputDirectory> defaults to the current working directory.
The base name used for naming the output files. The output files will be <outputDirectory>/<fileBaseName>.h and
<outputDirectory>/<fileBaseName>.cpp .
<fileBaseName> defaults to
BinaryData
.
The namespace that the embedded data objects will be declared in. This may be empty, and defaults to empty.
The paths of files to be embedded as binary data into the generated source files. If a directory is given, its contents will all be included recursively.
After the BinaryBuilder
executable has run, you'll have a .cpp and
.h file, and the header file will contain some code like this:
The static array of FileInfo
objects is initialized in the .cpp file. This header gives you direct access to an iterable array of
FileInfo
objects, which provide a convenient API for loading your embedded data into familiar C++ objects.
Limes also provides a CMake module, LimesBinaryBuilder.cmake
, that provides several utility functions for adding file generation commands to a target:
Usage:
Usage:
FileUtil
is a small command-line program that provides an OS-agnostic interface to common filesystem operations, including emulation of most Unix filesystem commands.
where <mode> is one one:
Convert an input path to an absolute path.
If <path> is an absolute path, prints
<path> ; otherwise, prints
<basePath>/<path> . If
<basePath> is not specified, it defaults to the current working directory.
Append content to a given file.
Note that the content is given as a single argument. If the file did not already exist, then an error will be raised if the –strict
option was given; otherwise, the content will be written to the file as if the write
command were called.
Concatenate and display contents of the given files.
If <outputFile> is specified, the concatenated output will be written to that file; otherwise, output is printed to the standard output.
Change the current working directory.
Copy files and directories to a new location.
In this command, the last argument is always the destination. If one input file is given, the destination may be a filename. If multiple inputs are given, the destination must be a directory. If the destination is a directory that doesn't exist, it will be created.
Check if two paths are equivalent.
Prints yes
if the two paths refer to the same filesystem object; otherwise, prints no
. If the –error
option is given, the result of the comparison is indicated by an exit code of 0 or 1 instead of printing to standard output.
Check if files and/or directories exist.
Prints yes
if every item in the passed list exists; otherwise prints no
. If the –error
option is given, the result of the comparison is indicated by an exit code of 0 or 1 instead of printing to standard output.
Print the target of a symbolic link.
This command follows the given symlink (and, if it points to another symlink, follows that symlink, etc), and prints the absolute path of the target to the standard output. If the optional –no-recurse
argument is present, then the recursive behavior is disabled, and the path of the passed symlink is printed, even if its target is another symlink.
Find files/directories matching a pattern.
Prints a list of absolute paths found that match the given globbing expression. If the <baseDir> option is given, files will be searched for in that directory. Otherwise, it defaults to the current working directory. If the
–error
flag is given, the program will exit with an error code if no files are found. Otherwise, 'No files found' will be printed.
Compute a hash of a file's contents.
Prints a crypographic hash of a file's contents to standard output. Available hash types are: md5
, sha1
, sha224
, sha256
, sha384
, and sha512
.
Create a symbolic link.
List directory contents.
The additional <directory> argument is optional; if omitted, this command lists the contents of the current working directory.
Create a directory.
Display the last modification time of a file or directory.
This command prints the last modification time of the file or directory to standard output in the form HH:MM:SS Day Month Year
, with the time in 24-hour format and the month as a 3-letter abbreviation; for example, 03:33:52 2 May 2022
.
Convert a path to the current platform's preferred directory separators.
Converts any directory separators in <path> to the preferred directory separator for the current platform. Unlike most other commands, this one does not make the passed path absolute if a relative path was given.
Prints the contents of the PATH
environment variable.
Prints the contents of the PATH
environment variable as a list of absolute paths to directories, one per line of output.
Prepend content to a file.
Note that the content is given as a single argument. If the file did not already exist, then an error will be raised if the –strict
option was given; otherwise, the content will be written to the file as if the write
command were called.
Print the absolute path of the current working directory
Get a path relative to another location.
If <basePath> is not specified, it defaults to the current working directory.
Rename a file or directory.
Remove files and/or directories.
Prints the current platform's preferred directory separator.
Prints the size of a file or directory, in bytes.
The size is printed to standard output and is represented as bytes. If a directory is passed, this command reports the cumulative size of all the directory's contents. If no file or directory is specified, this command prints the capacity of the entire filesystem.
Prints the amount of remaining space on the filesystem, in bytes
Update modification time of files or directories
If the –no-create
option is specified, files/directories in the input list that don't already exist will simply be ignored. Otherwise, they will be created.
Print the type of a filesystem entry
If nothing exists at <path> , raise an error. Otherwise, prints one of
file
, directory
, or symlink
describing what exists at the given path.
Locate an executable.
Searches for an executable file named <programName> in each of the directories in the
PATH
environment variable and prints the absolute path of the first match found. If the <programName> is omitted, this command prints the path of the currently running FileUtil executable itself.
Write content to a file.
Note that the content is given as a single argument. If the –no-overwrite
option is given, then an error is raised if the file already existed; otherwise, it will be overwritten.