![]() |
lingua-franca 0.10.1
Lingua Franca code generator
|
Utilities for file operations. More...
Static Public Member Functions | |
| static void | arduinoDeleteHelper (Path srcGenPath, boolean threadingOn) throws IOException |
| Delete unused Files from Arduino-CLI based compilation. | |
| static void | copyDirectory (final Path srcDir, final Path dstDir, final boolean skipIfUnchanged) throws IOException |
| Copy the given source directory into the given destination directory. | |
| static void | copyDirectoryContents (final Path srcDir, final Path dstDir) throws IOException |
| Recursively copy the contents of the given source directory into the given destination directory. | |
| static void | copyDirectoryContents (final Path srcDir, final Path dstDir, final boolean skipIfUnchanged) throws IOException |
| Recursively copy the contents of the given source directory into the given destination directory. | |
| static void | copyFile (Path srcFile, Path dstFile) throws IOException |
| Copy a given source file to a given destination file. | |
| static void | copyFile (Path srcFile, Path dstFile, boolean skipIfUnchanged) throws IOException |
| Copy a given source file to a given destination file. | |
| static void | copyFileFromClassPath (final String entry, final Path dstDir, final boolean skipIfUnchanged) throws IOException |
| Look up the given entry in the classpath. | |
| static void | copyFilesOrDirectories (List< String > entries, Path dstDir, FileConfig fileConfig, MessageReporter messageReporter, boolean fileEntriesOnly) |
| Given a list of files or directories, attempt to find each entry based on the given generator context and copy it to the destination directory. | |
| static void | copyFromClassPath (final String entry, final Path dstDir, final boolean skipIfUnchanged, final boolean contentsOnly) throws IOException |
| Look up the given entry in the classpath. | |
| static void | copyFromFileSystem (Path entry, Path dstDir, boolean contentsOnly) throws IOException |
| If the given entry is a file, then copy it into the destination. | |
| static void | createDirectoryIfDoesNotExist (File dir) |
| static void | delete (Path fileOrDirectory) throws IOException |
| Delete the given file or directory if it exists. | |
| static void | deleteDirectory (Path dir) throws IOException |
| Recursively delete a directory if it exists. | |
| static Path | findAndCopyFile (String file, Path dstDir, FileConfig fileConfig) |
| Find the given file in the package and return the path to the file that was found; null if it was not found. | |
| static Path | findInPackage (Path fileOrDirectory, FileConfig fileConfig) |
| Return an absolute path to the given file or directory if it can be found within the package. | |
| static IResource | getIResource (java.net.URI uri) |
| Get the specified uri as an Eclipse IResource or null if it is not found. | |
| static IResource | getIResource (Path path) |
| Get the specified path as an Eclipse IResource or null if it is not found. | |
| static IResource | getIResource (Resource r) |
| Get the iResource corresponding to the provided resource if it can be found. | |
| static Path | getRelativePath (Resource source, Resource target) |
| static Resource | getResourceFromClassPath (ResourceSet resourceSet, final String entry) throws IOException |
| Fetch a resource from the jar. | |
| static List< Path > | globFilesEndsWith (Path currentDir, String str) |
| Return a list of files ending with "str". | |
| static boolean | isCFile (Path path) |
| Return true if the given path points to a C file, false otherwise. | |
| static boolean | isSame (String text, Path path) throws IOException |
| Check if the content of a file is equal to a given string. | |
| static java.net.URI | locateFile (String path, Resource resource) |
| Parse the string as file location and return it as URI. | |
| static String | nameWithoutExtension (Path file) |
| Return the name of the file excluding its file extension. | |
| static String | nameWithoutExtension (Resource r) |
| Return the name of the file associated with the given resource, excluding its file extension. | |
| static void | relativeIncludeHelper (Path dir, Path includePath, MessageReporter messageReporter) throws IOException |
| Convert all includes recursively inside files within a specified folder to relative links. | |
| static IPath | toIPath (URI uri) |
| Return an org.eclipse.core.runtime.Path object corresponding to the given URI. | |
| static Path | toPath (Resource resource) |
| Return a java.nio.Path object corresponding to the given Resource. | |
| static Path | toPath (URI uri) |
| Return a java.nio.Path object corresponding to the given URI. | |
| static String | toUnixString (Path path) |
| Convert a given path to a unix-style string. | |
| static void | writeToFile (CharSequence text, Path path) throws IOException |
| Write text to a file. | |
| static void | writeToFile (String text, Path path) throws IOException |
| Write text to a file. | |
| static void | writeToFile (String text, Path path, boolean skipIfUnchanged) throws IOException |
| Write text to a file. | |
Utilities for file operations.
|
static |
Delete unused Files from Arduino-CLI based compilation.
Arduino-CLI (the build system) uses lazy compilation (i.e. compiles every file recursively from a source directory). This does the work of CMake by explicitly deleting files that shouldn't get compiled by the CLI. Generally, we delete all CMake artifacts and multithreaded support files (including semaphores and thread folders)
| srcGenPath | The folder to search for folders and files to delete. |
| threadingOn | Whether threading is enabled. |
| IOException | If the given folder and unneeded files cannot be deleted. |
|
static |
Copy the given source directory into the given destination directory.
For example, if the source directory is foo/bar and the destination is baz, then copies of the contents of foo/bar will be located in baz/bar.
| srcDir | The source directory path. |
| dstDir | The destination directory path. |
| skipIfUnchanged | If true, don't overwrite anything in the destination if its content would not be changed. |
| IOException | If the operation fails. |
|
static |
Recursively copy the contents of the given source directory into the given destination directory.
Existing files of the destination may be overwritten.
| srcDir | The directory to copy files from. |
| dstDir | The directory to copy files to. |
| IOException | if copy fails. |
|
static |
Recursively copy the contents of the given source directory into the given destination directory.
Existing files of the destination may be overwritten.
| srcDir | The source directory path. |
| dstDir | The destination directory path. |
| skipIfUnchanged | If true, don't overwrite anything in the destination if its content would not be changed. |
| IOException | If the operation fails. |
|
static |
Copy a given source file to a given destination file.
This also creates new directories for any directories on the path to dstFile that do not yet exist.
| srcFile | The source file path. |
| dstFile | The destination file path. |
| IOException | if copy fails. |
|
static |
Copy a given source file to a given destination file.
This also creates new directories on the path to dstFile that do not yet exist.
| srcFile | The source file path. |
| dstFile | The destination file path. |
| skipIfUnchanged | If true, don't overwrite the destination file if its content would not be changed. |
| IOException | If the operation fails. |
|
static |
Look up the given entry in the classpath.
If it is found and is a file, copy it into the destination directory. If the entry is not found or not a file, throw an exception.
| entry | A file copy to the destination directory. |
| dstDir | A directory to copy the entry to. |
| skipIfUnchanged | If true, don't overwrite the destination file if its content would not be changed. |
| IOException | If the operation failed. |
|
static |
Given a list of files or directories, attempt to find each entry based on the given generator context and copy it to the destination directory.
Entries are searched for in the file system first, relative to the source file and relative to the package root. Entries that cannot be found in the file system are looked for on the class path.
If contentsOnly is true, then for each entry that is a directory, only its contents are copied, not the directory itself. For example, if the entry is a directory foo/bar and the destination is baz, then copies of the contents of foo/bar will be located directly in baz. If contentsOnly is false, then copies of the contents of foo/bar will be located in baz/bar.
| entries | The list of file or directory entries to copy. |
| dstDir | The destination directory. |
| fileConfig | The file configuration that specifies where to find entries. |
| messageReporter | Used to report errors and warnings. |
| fileEntriesOnly | Whether to copy only file entries. |
|
static |
Look up the given entry in the classpath.
If it is a file, copy it into the destination directory. If the entry is a directory and contentsOnly is true, then copy its contents to the destination directory. If the entry is a directory and contentsOnly is true, then copy it including its contents to the destination directory.
This also creates new directories for any directories on the destination path that do not yet exist.
| entry | The entry to be found on the class path and copied to the given destination. |
| dstDir | The file system path that found files are to be copied to. |
| skipIfUnchanged | If true, don't overwrite the file or directory if its content would not be changed |
| contentsOnly | If true and the entry is a directory, then copy its contents but not the directory itself. |
| IOException | If the operation failed. |
|
static |
If the given entry is a file, then copy it into the destination.
If the entry is a directory and contentsOnly is true, then copy its contents to the destination directory. If the entry is a directory and contentsOnly is true, then copy it including its contents to the destination directory.
| entry | A file or directory to copy to the destination directory. |
| dstDir | A directory to copy the entry or its contents to. |
| contentsOnly | If true and entry is a directory, then copy its contents but not the directory itself. |
| IOException | If the operation fails. |
|
static |
|
static |
Delete the given file or directory if it exists.
If fileOrDirectory is a directory, deletion is recursive.
| fileOrDirectory | The file or directory to delete. |
| IOException | If the operation failed. |
|
static |
Recursively delete a directory if it exists.
| IOException | If an I/O error occurs. |
|
static |
Find the given file in the package and return the path to the file that was found; null if it was not found.
| file | The file to look for. |
| dstDir | The directory to copy it to. |
| fileConfig | The file configuration that specifies where look for the file. |
|
static |
Return an absolute path to the given file or directory if it can be found within the package.
Otherwise, return null.
NOTE: If the given file or directory is given as an absolute path but cannot be found, it is interpreted as a relative path with respect to the project root.
| fileOrDirectory | The file or directory to look for. |
| fileConfig | A file configuration that determines where the package is located. |
|
static |
Get the specified uri as an Eclipse IResource or null if it is not found.
Also returns null if this is not called from within a running Eclipse instance.
| uri | A java.net.uri of the form "file://path". |
|
static |
Get the specified path as an Eclipse IResource or null if it is not found.
|
static |
Get the iResource corresponding to the provided resource if it can be found.
|
static |
|
static |
Fetch a resource from the jar.
| resourceSet | The resource set |
| entry | The path to the resource within the jar |
| IOException | If the resource cannot be found. |
|
static |
Return a list of files ending with "str".
| currentDir | The current directory. |
| str | The pattern to match against. |
|
static |
Return true if the given path points to a C file, false otherwise.
|
static |
Check if the content of a file is equal to a given string.
| text | The text to compare with. |
| path | The file to compare with. |
|
static |
Parse the string as file location and return it as URI.
Supports URIs, plain file paths, and paths relative to a model.
| path | the file location as string. |
| resource | the model resource this file should be resolved relatively. May be null. |
|
static |
Return the name of the file excluding its file extension.
| file | A Path object |
|
static |
Return the name of the file associated with the given resource, excluding its file extension.
| r | Any Resource. |
| IllegalArgumentException | If the resource has an invalid URI. |
|
static |
Convert all includes recursively inside files within a specified folder to relative links.
| dir | The folder to search for includes to change. |
| includePath | The include path. |
| messageReporter | Error reporter |
| IOException | If the given set of files cannot be relativized. |
|
static |
Return an org.eclipse.core.runtime.Path object corresponding to the given URI.
| IllegalArgumentException | If the given URI is invalid. |
|
static |
Return a java.nio.Path object corresponding to the given Resource.
| IllegalArgumentException | If the given resource has an invalid URI. |
|
static |
Return a java.nio.Path object corresponding to the given URI.
| IllegalArgumentException | If the given URI is invalid. |
|
static |
Convert a given path to a unix-style string.
This ensures that '/' is used instead of '\' as file separator.
|
static |
Write text to a file.
| text | The text to be written. |
| path | The file to write the code to. |
|
static |
Write text to a file.
| text | The text to be written. |
| path | The file to write the code to. |
|
static |
Write text to a file.
| text | The text to be written. |
| path | The file to write the code to. |
| skipIfUnchanged | If true, don't overwrite the destination file if its content would not be changed |