public class FileTools
extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BINARY_CHECK_LENGTH |
static String |
CELL_PIN_DEFAULTS_FILE_NAME
Location of the cell pins default data file
|
static String |
DATA_FOLDER_NAME
Data folder name
|
static String |
DEVICE_CACHE_FILE_SUFFIX
Suffix of the device part files
|
static String |
DEVICE_FILE_SUFFIX
Suffix of the device part files
|
static String |
DEVICE_FOLDER_NAME
Folder where device files are kept
|
static int[] |
emptyIntArray
Static empty array to save on memory
|
static short[] |
emptyShortArray
Static empty array to save on memory
|
static String[] |
emptyStringArray
Static empty array to save on memory
|
static int[] |
GZIP_START_BYTES |
static String |
IMAGES_FOLDER_NAME
Images source folder name
|
static String |
JARS_FOLDER_NAME
Java library folder name
|
static String |
MD5_DATA_FILE_SUFFIX
Suffix added to data file names to capture md5 status
|
static int |
PART_DB_FILE_VERSION
Part Database File Version
|
static String |
PART_DB_PATH
Location of the main parts database file
|
static String |
PART_DUMP_FILE_NAME
File name created from Vivado for all supported parts for RapidWright
|
static String |
PYTHON_FOLDER_NAME
Python source folder name
|
static String |
RAPIDWRIGHT_DATA_URL
Base URL for download data files
|
static String |
RAPIDWRIGHT_VARIABLE_NAME
Environment Variable Name which points to the RapidWright project on disk
|
static String |
ROUTETHRU_FOLDER_NAME
Location of cached routethru helper files
|
static String |
TCL_FOLDER_NAME
Tcl source folder name
|
static String |
UNISIM_DATA_FILE_NAME
File name of the UnisimManager initialization data file (replaced HDI_PRIMITIVES_FILE_NAME and VALID_CELL_PLACEMENTS_FILE_NAME)
|
static int |
UNISIM_DATA_FILE_VERSION
Unisim Data File Version
|
static String[] |
UNPACK_FOLDERS
Supporting data folders packed in standalone jars of RapidWright
|
Constructor and Description |
---|
FileTools() |
Modifier and Type | Method and Description |
---|---|
static Path |
appendExtension(Path path,
String extension)
Appends an extension to the file.
|
static void |
blockSystemExitCalls()
For Java 16 and below, calling this method will prevent System.exit() calls
from exiting the JVM and instead throws a
SecurityException in its
place. |
static void |
close(InputStream is) |
static void |
close(ZipFile zip) |
static Path |
compressFileUsingGZIP(Path uncompressedFile)
Compresses the provided file using GZIP (adds '.gz' extension)
|
static boolean |
copyFile(String src,
String dst)
Copies a file from one location (src) to another (dst).
|
static boolean |
copyFolder(String srcDirectoryPath,
String dstDirectoryPath,
boolean recursive)
Copies a folder and its files from the path defined in srcDirectoryPath to a new folder
at dstDirectoryPath.
|
static boolean |
copyFolderContents(String src,
String dst,
boolean recursive)
Copies the folder contents of the folder specified by src to folder specified as dst.
|
static boolean |
cygwinInstalled()
Checks if Cygwin is installed on the system
|
static Path |
decompressGZIPFile(Path gzipFile)
Decompresses a gzipped file to a file with the '.gz' extension removed.
|
static boolean |
deleteFile(String fileName)
Delete the file/folder in the file system called fileName
|
static boolean |
deleteFolder(String folderName)
Delete the folder and recursively files and folders below
|
static boolean |
deleteFolderContents(String path)
Deletes everything in the directory given by path, but does not
delete the folder itself.
|
static String |
ensureCorrectDataFile(String name)
Ensures that the specified RapidWright data file is the correct version and present based
on the MD5 hash in @link
DataVersions |
static void |
ensureDataFilesAreStaticInstallFriendly()
Downloads and generates all potential data files to make this RapidWright
installation static friendly.
|
static void |
ensureDataFilesAreStaticInstallFriendly(String... devices)
Downloads and generates all potential data files to make this RapidWright
installation static friendly.
|
static void |
errorIfFileDoesNotExist(String fileName)
Convenience assertion to assert that a file exists
|
static List<String> |
execCommandGetOutput(boolean includeError,
String... command)
Runs the provided command (arguments must be separate) and gathers the
standard output followed by the standard error.
|
static void |
forceUpdateAllDataFiles()
RapidWright downloads data files on demand to avoid large downloads.
|
static List<String> |
getAllDependentDataFiles(String... devices)
Gets the list of all relative dependent data files given the set of devices
provided.
|
static List<Path> |
getAllFilesWithSuffix(Path root,
String suffix)
Gets all files (Path objects) recursively (including all sub-directories)
starting at a root directory of a particular extension (or file name suffix).
|
static BufferedInputStream |
getAutoBufferedInputStream(InputStream is)
Creates a new BufferedInputStream that wraps a possibly-compressed input stream.
|
static List<FamilyType> |
getAvailableFamilies()
This method returns an ArrayList of family types currently supported
|
static List<String> |
getAvailableParts(FamilyType type)
Checks for all device files present in the current RapidWright family path and returns
a list of strings of those part names available to be used by the tool within the specified family.
|
static ArrayList<String> |
getCommandOutput(String[] command)
Generic method to run a command in the current shell and return its standard output and standard error
|
static String |
getContainerName(String fileName)
Translates RapidWright data file names to Azure Blob Container-friendly names
|
static String |
getCurrentDataVersion(String dataFileName)
Returns the expected MD5 sum of the named data file
|
static FilenameFilter |
getDCPFilenameFilter()
Gets a filename filter for DCP files (ends with .dcp).
|
static Path |
getDecompressedGZIPFileName(Path gzipFile)
Gets a Path to the corresponding uncompressed name of the provided path.
|
static String |
getDeviceFolderResourceName() |
static String |
getDeviceResourceCache(Part part) |
static String |
getDeviceResourceName(Part part) |
static String |
getDeviceResourceSuffix(Part part) |
static String |
getDirectorySeparator()
Gets and returns the file separator character for the given OS
|
static FilenameFilter |
getEDNFilenameFilter()
Gets a filename filter for EDN files (ends with .edn).
|
static String |
getExecJarStoragePath() |
static FilenameFilter |
getFilenameFilter(String matches)
Creates a custom filename filter that uses the provided
matches string on the name of the file (not the path).
|
static long |
getFileSize(String fileName)
Gets the size of the file in bytes.
|
static Pair<InputStream,Long> |
getInputStreamFromZipFile(String zipFileName,
String fileEndsWith) |
static int |
getJavaVersion()
Gets the current runtime version number.
|
static com.esotericsoftware.kryo.io.Input |
getKryoGzipInputStream(InputStream is)
Creates a Kryo input stream that decompresses a gzip compressed input stream.
|
static com.esotericsoftware.kryo.io.Input |
getKryoGzipInputStream(String fileName)
Creates a Kryo input stream that decompresses a gzip compressed input file.
|
static com.esotericsoftware.kryo.io.Output |
getKryoGzipOutputStream(OutputStream os)
Creates a Kryo output stream that instantiates a gzip compression stream to
an output stream.
|
static com.esotericsoftware.kryo.io.Output |
getKryoGzipOutputStream(String fileName)
Creates a Kryo output stream that instantiates a gzip compression stream to
an output file.
|
static com.esotericsoftware.kryo.io.Input |
getKryoInputStreamWithoutInflater(InputStream in)
Wraps the provided input stream with a kryo stream.
|
static com.esotericsoftware.kryo.Kryo |
getKryoInstance() |
static com.esotericsoftware.kryo.io.Output |
getKryoOutputStreamWithoutDeflater(OutputStream os)
Wraps the provided output stream with a kryo stream.
|
static com.esotericsoftware.kryo.io.Input |
getKryoZstdInputStream(InputStream input)
Creates a Kryo input stream from decompressing a Zstandard compressed input
stream.
|
static com.esotericsoftware.kryo.io.Input |
getKryoZstdInputStream(String fileName)
Creates a Kryo input stream from decompressing Zstandard compressed input
file.
|
static com.esotericsoftware.kryo.io.Output |
getKryoZstdOutputStream(OutputStream os)
Creates a Kryo output stream that instantiates a Zstandard compression stream
from an output stream.
|
static com.esotericsoftware.kryo.io.Output |
getKryoZstdOutputStream(String fileName)
Creates a Kryo output stream that instantiates a Zstandard compression stream
to an output file.
|
static List<String> |
getLastNLinesFromTextFile(String fileName,
int n)
Gets the last n number of lines from a text file and returns them.
|
static ArrayList<String> |
getLinesFromInputStream(InputStream in) |
static ArrayList<String> |
getLinesFromTextFile(String fileName)
This is a simple method that will read in a text file and put each line in a
string and put all the lines in an ArrayList.
|
static String |
getOSName() |
static InputStream |
getPartDumpResourceStream()
Gets an input stream to the file containing a CSV file of valid parts for RapidWright.
|
static String |
getPartFolderResourceName(FamilyType familyType)
Gets and returns the path of the folder where the family type resides.
|
static String |
getPartFolderResourceName(Part part)
Gets and returns the path of the folder where the part files resides for deviceName.
|
static BufferedReader |
getProperInputStream(String fileName)
Creates a BufferedReader that reads an input file and determines based on file
extension (*.gz) if the file is gzipped or not.
|
static BufferedWriter |
getProperOutputStream(String fileName)
Creates a new BufferedWriter that will either write out text or a gzipped
compressed version of text based on the file extension (*.gz
-> gzipped, all
others target an uncompressed output. |
static String |
getRapidWrightPath()
Gets and returns the value of the environment variable RAPIDWRIGHT_PATH.
|
static String |
getRapidWrightResourceFileName(String name)
Finds and returns a file name that can be read for the corresponding
RapidWright resource.
|
static InputStream |
getRapidWrightResourceInputStream(String name)
Identifies the proper location for a RapidWright data resource and
returns an opened InputStream to that resource.
|
static String |
getRouteThruFileName(String deviceName)
Gets the relative routethru file name for the given device.
|
static String |
getStoredMD5FromFile(Path md5File)
Extracts the md5 checksum from a previously created MD5 sum file.
|
static String |
getTimeStamp()
Creates a formatted string of the current time in a sortable format ("yyyy mm dd HH mm ss").
|
static String |
getTimeString()
This method will get and return the current time as a string formatted in the
same way used in most Xilinx report and XDL files.
|
static String |
getUniqueProcessAndHostID() |
static InputStream |
getUnisimDataResourceStream()
Gets an input stream to the file containing valid cell placements of the hdi primitives.
|
static String |
getVivadoPath()
Gets the full path to the vivado executable if it is set in the PATH
environment variable.
|
static String |
getVivadoVersion()
Gets the current version of Vivado on the system PATH.
|
static InputStream |
getZstdInputStream(String fileName)
Creates an input stream that decompresses a Zstandard compressed input file.
|
static OutputStream |
getZstdOutputStream(OutputStream os)
Wraps the provided output stream with a Zstandard compression stream.
|
static OutputStream |
getZstdOutputStream(String fileName)
Creates a Zstandard compression stream to an output file.
|
static boolean |
isDataBinary(InputStream is) |
static boolean |
isExecutableOnPath(String execName)
Checks if a particular executable is available on the current path
|
static boolean |
isFileBinary(Path fileName)
Uses a similar algorithm to diff to determine if the file
is a binary file by looking at the first 4k bytes to see if
there are any null characters.
|
static boolean |
isFileBinary(String fileName)
Uses a similar algorithm to diff to determine if the file
is a binary file by looking at the first 4k bytes to see if
there are any null characters.
|
static boolean |
isFileGzipped(Path path) |
static boolean |
isFileNewer(Path fileName1,
Path fileName2)
Is fileName1 newer than fileName2?
|
static boolean |
isFileNewer(String fileName1,
String fileName2)
Is fileName1 newer than fileName2?
|
static boolean |
isVivadoAtLeastVersion(int major,
int minor)
Checks if Vivado is available and if it is available if it is at least of the
version major.minor or later.
|
static boolean |
isVivadoCompatible()
Checks that Vivado is on current PATH and returns true if RapidWright should be
compatible with the version of vivado available.
|
static boolean |
isVivadoOnPath()
Checks if vivado is available on current PATH (uses unix 'which' or windows 'where').
|
static boolean |
isWindows() |
static Object |
loadFromFile(String fileName)
Loads a serialized Java object from fileName.
|
static void |
main(String[] args) |
static boolean |
makeDir(String dirName)
Creates a directory in the current path called dirName.
|
static boolean |
makeDirs(String dirName)
Creates a directory in the current path called dirName.
|
static boolean |
overrideDataFileDownload() |
static HashMap<String,Integer> |
readHashMap(com.esotericsoftware.kryo.io.Input dis,
Integer[] allInts) |
static int[] |
readIntArray(com.esotericsoftware.kryo.io.Input dis) |
static Object |
readObjectFromKryoFile(InputStream in) |
static <T> T |
readObjectFromKryoFile(InputStream in,
Class<T> c) |
static Object |
readObjectFromKryoFile(Path fileName) |
static <T> T |
readObjectFromKryoFile(Path fileName,
Class<T> c) |
static Object |
readObjectFromKryoFile(String fileName) |
static <T> T |
readObjectFromKryoFile(String fileName,
Class<T> c) |
static short[] |
readShortArray(com.esotericsoftware.kryo.io.Input dis) |
static String |
readString(DataInputStream dis) |
static String[] |
readStringArray(com.esotericsoftware.kryo.io.Input dis) |
static String |
removeFileExtension(String fileName)
Takes a file name and removes everything after the last '.' inclusive
|
static boolean |
renameFile(String oldFileName,
String newFileName) |
static Path |
replaceDir(Path path,
Path newDir) |
static Path |
replaceExtension(Path path,
String newExtension)
Replaces the file extension of the provided file name.
|
static Integer |
runCommand(List<String> command,
String logFileName)
A generic method to run a command from the system command line.
|
static Integer |
runCommand(String command,
boolean verbose)
A generic method to run a command from the system command line.
|
static Integer |
runCommand(String command,
boolean verbose,
String[] environ,
File runDir)
A generic method to run a command from the system command line.
|
static boolean |
saveToFile(Object o,
String fileName)
Serialize the Object o to a the file specified by fileName.
|
static void |
setOverrideDataFileDownload(boolean value) |
static boolean |
unPackSupportingJarData()
Used for unpacking data files inside a standalone jar to be used
for regular use by RapidWright.
|
static void |
unzipFile(String zipFileName,
String destDirectory) |
static void |
updateAllDataFiles() |
static boolean |
useUnsafeStreams()
Checks if Kryo Unsafe Streams can/should be used.
|
static boolean |
writeHashMap(com.esotericsoftware.kryo.io.Output dos,
HashMap<String,Integer> map) |
static boolean |
writeIntArray(com.esotericsoftware.kryo.io.Output dos,
int[] intArray) |
static void |
writeLinesToTextFile(List<String> lines,
String fileName)
This is a simple method that writes the elements of an ArrayList of Strings
into lines in the text file fileName.
|
static void |
writeObjectToKryoFile(Path fileName,
Object o) |
static void |
writeObjectToKryoFile(Path fileName,
Object o,
boolean writeClass) |
static void |
writeObjectToKryoFile(String fileName,
Object o) |
static void |
writeObjectToKryoFile(String fileName,
Object o,
boolean writeClass) |
static boolean |
writeShortArray(com.esotericsoftware.kryo.io.Output dos,
short[] intArray) |
static boolean |
writeString(DataOutputStream dos,
String str) |
static boolean |
writeStringArray(com.esotericsoftware.kryo.io.Output dos,
String[] stringArray) |
static void |
writeStringToTextFile(String text,
String fileName)
This is a simple method that writes a String to a file and adds a new line.
|
public static final String RAPIDWRIGHT_VARIABLE_NAME
public static final String DEVICE_FILE_SUFFIX
public static final String DEVICE_CACHE_FILE_SUFFIX
public static final String DATA_FOLDER_NAME
public static final String TCL_FOLDER_NAME
public static final String JARS_FOLDER_NAME
public static final String IMAGES_FOLDER_NAME
public static final String PYTHON_FOLDER_NAME
public static final String DEVICE_FOLDER_NAME
public static final String UNISIM_DATA_FILE_NAME
public static final String PART_DUMP_FILE_NAME
public static final String PART_DB_PATH
public static final String CELL_PIN_DEFAULTS_FILE_NAME
public static final String ROUTETHRU_FOLDER_NAME
public static final String[] UNPACK_FOLDERS
public static int[] emptyIntArray
public static short[] emptyShortArray
public static String[] emptyStringArray
public static final int PART_DB_FILE_VERSION
public static final int UNISIM_DATA_FILE_VERSION
public static final String RAPIDWRIGHT_DATA_URL
public static final String MD5_DATA_FILE_SUFFIX
public static final int BINARY_CHECK_LENGTH
public static final int[] GZIP_START_BYTES
public static com.esotericsoftware.kryo.io.Output getKryoZstdOutputStream(String fileName)
fileName
- Name of the file to target.public static com.esotericsoftware.kryo.io.Output getKryoZstdOutputStream(OutputStream os)
os
- The existing output stream to wrap.public static OutputStream getZstdOutputStream(String fileName)
fileName
- Name of the file to target.public static OutputStream getZstdOutputStream(OutputStream os)
os
- The existing output stream.public static com.esotericsoftware.kryo.io.Output getKryoGzipOutputStream(String fileName)
fileName
- Name of the file to target.public static com.esotericsoftware.kryo.io.Output getKryoGzipOutputStream(OutputStream os)
os
- The output stream to wrap.public static com.esotericsoftware.kryo.io.Output getKryoOutputStreamWithoutDeflater(OutputStream os)
FileTools.useUnsafeStreams()
to decide on using unsafe or not.os
- The output stream to wrap.public static com.esotericsoftware.kryo.io.Input getKryoZstdInputStream(String fileName)
fileName
- Name of the file to read from.public static com.esotericsoftware.kryo.io.Input getKryoZstdInputStream(InputStream input)
input
- The input stream to read from.public static InputStream getZstdInputStream(String fileName)
fileName
- Name of the file to read from.public static com.esotericsoftware.kryo.io.Input getKryoGzipInputStream(String fileName)
fileName
- Name of the file read from.public static com.esotericsoftware.kryo.io.Input getKryoGzipInputStream(InputStream is)
is
- The gzip compressed input stream to read from.public static com.esotericsoftware.kryo.io.Input getKryoInputStreamWithoutInflater(InputStream in)
FileTools.useUnsafeStreams()
to decide on using unsafe or not.in
- The input stream to wrap.public static BufferedInputStream getAutoBufferedInputStream(InputStream is) throws IOException
is
- The input stream to wrap.IOException
public static boolean useUnsafeStreams()
public static int getJavaVersion()
public static BufferedReader getProperInputStream(String fileName)
fileName
- Name of the text or gzipped filepublic static BufferedWriter getProperOutputStream(String fileName)
->
gzipped, all
others target an uncompressed output.fileName
- Name of the output file. Will be gzipped if has *.gz extension.public static HashMap<String,Integer> readHashMap(com.esotericsoftware.kryo.io.Input dis, Integer[] allInts)
public static boolean writeHashMap(com.esotericsoftware.kryo.io.Output dos, HashMap<String,Integer> map)
public static boolean writeStringArray(com.esotericsoftware.kryo.io.Output dos, String[] stringArray)
public static String[] readStringArray(com.esotericsoftware.kryo.io.Input dis)
public static boolean writeIntArray(com.esotericsoftware.kryo.io.Output dos, int[] intArray)
public static boolean writeShortArray(com.esotericsoftware.kryo.io.Output dos, short[] intArray)
public static int[] readIntArray(com.esotericsoftware.kryo.io.Input dis)
public static short[] readShortArray(com.esotericsoftware.kryo.io.Input dis)
public static boolean writeString(DataOutputStream dos, String str)
public static String readString(DataInputStream dis)
public static Object loadFromFile(String fileName)
fileName
- The file to read from.public static boolean saveToFile(Object o, String fileName)
o
- The object to serialize.fileName
- Name of the file to serialize the object to.public static void writeLinesToTextFile(List<String> lines, String fileName)
lines
- The ArrayList of Strings to be writtenfileName
- Name of the text file to save the ArrayList topublic static void writeStringToTextFile(String text, String fileName)
text
- the String to write to the filefileName
- Name of the text file to save the ArrayList topublic static ArrayList<String> getLinesFromTextFile(String fileName)
fileName
- Name of the text file to load.public static List<String> getLastNLinesFromTextFile(String fileName, int n)
fileName
- Name of the text filen
- Number of last lines to getpublic static ArrayList<String> getLinesFromInputStream(InputStream in)
public static String removeFileExtension(String fileName)
fileName
- The input file namepublic static boolean makeDir(String dirName)
dirName
- Name of the directory to be created.public static boolean makeDirs(String dirName)
dirName
- Name of the directory to be created.public static long getFileSize(String fileName)
fileName
- Name of the file to get the size of.public static boolean deleteFile(String fileName)
fileName
- Name of the file to deletepublic static boolean deleteFolderContents(String path)
path
- The path to the folder where all its contents will be deleted.public static boolean deleteFolder(String folderName)
folderName
- public static boolean renameFile(String oldFileName, String newFileName)
public static boolean copyFile(String src, String dst)
src
- Source file to read fromdst
- Destination file to write topublic static boolean copyFolder(String srcDirectoryPath, String dstDirectoryPath, boolean recursive)
srcDirectoryPath
- The name of the source folder to copy.dstDirectoryPath
- The destination of where the copy of the folder should be located.recursive
- A flag denoting if the sub folders of source should be copied.public static boolean copyFolderContents(String src, String dst, boolean recursive)
src
- The source folder to copy.dst
- The location of where the copy of the contents of src will be located.recursive
- A flag indicating if sub folders and their contents should be
copied.public static void errorIfFileDoesNotExist(String fileName)
fileName
- Name of the file to checkpublic static String getRapidWrightPath()
public static String getExecJarStoragePath()
public static void updateAllDataFiles()
public static void forceUpdateAllDataFiles()
public static void ensureDataFilesAreStaticInstallFriendly(String... devices)
devices
- The set of devices intended to be used for this installation
(this simply saves download and generation time).public static void ensureDataFilesAreStaticInstallFriendly()
public static List<String> getAllDependentDataFiles(String... devices)
devices
- The list of devices to be used to compile the list of needed
data files.public static String ensureCorrectDataFile(String name)
DataVersions
name
- Name of the RapidWright data file resourcepublic static String getStoredMD5FromFile(Path md5File)
md5File
- The path of the existing md5 sum filepublic static InputStream getRapidWrightResourceInputStream(String name)
name
- Name of the resource.public static String getRapidWrightResourceFileName(String name)
name
- Name of the RapidWright resourcepublic static InputStream getUnisimDataResourceStream()
public static InputStream getPartDumpResourceStream()
public static String getPartFolderResourceName(Part part)
part
- The part to get its corresponding folder path.public static String getPartFolderResourceName(FamilyType familyType)
familyType
- The family type corresponding folder path.public static String getDeviceFolderResourceName()
public static String getDeviceResourceName(Part part)
public static String getDeviceResourceSuffix(Part part)
public static String getDeviceResourceCache(Part part)
public static String getRouteThruFileName(String deviceName)
deviceName
- Name of the devicepublic static List<String> getAvailableParts(FamilyType type)
type
- The specified family type.public static List<FamilyType> getAvailableFamilies()
public static String getTimeString()
public static String getTimeStamp()
public static String getDirectorySeparator()
public static boolean cygwinInstalled()
public static void writeObjectToKryoFile(Path fileName, Object o)
public static void writeObjectToKryoFile(String fileName, Object o)
public static void writeObjectToKryoFile(Path fileName, Object o, boolean writeClass)
public static void writeObjectToKryoFile(String fileName, Object o, boolean writeClass)
public static Object readObjectFromKryoFile(String fileName)
public static Object readObjectFromKryoFile(Path fileName)
public static <T> T readObjectFromKryoFile(String fileName, Class<T> c)
public static <T> T readObjectFromKryoFile(Path fileName, Class<T> c)
public static <T> T readObjectFromKryoFile(InputStream in, Class<T> c)
public static Object readObjectFromKryoFile(InputStream in)
public static com.esotericsoftware.kryo.Kryo getKryoInstance()
public static boolean isFileNewer(Path fileName1, Path fileName2)
fileName1
- fileName2
- public static boolean isFileNewer(String fileName1, String fileName2)
fileName1
- fileName2
- public static Pair<InputStream,Long> getInputStreamFromZipFile(String zipFileName, String fileEndsWith)
public static void close(InputStream is)
public static void close(ZipFile zip)
public static ArrayList<String> getCommandOutput(String[] command)
command
- The command to runpublic static Integer runCommand(String command, boolean verbose)
command
- The command to execute. This method blocks until the command finishes.verbose
- When true, it will first print to std.out the command and also all of the
command's output (both std.out and std.err) to std.out.public static Integer runCommand(String command, boolean verbose, String[] environ, File runDir)
command
- The command to execute. This method blocks until the command
finishes.verbose
- When true, it will first print to std.out the command and also
all of the command's output (both std.out and std.err) to
std.out.environ
- array of strings, each element of which has environment
variable settings in the format name=value, or null if the
subprocess should inherit the environment of the current
process.runDir
- the working directory of the subprocess, or null if the
subprocess should inherit the working directory of the current
process.public static Integer runCommand(List<String> command, String logFileName)
command
- The command to execute. This method blocks until the command finishes.logFileName
- Name of the log file to produce that will capture stderr and stdout.public static String getUniqueProcessAndHostID()
public static boolean isFileBinary(Path fileName)
fileName
- Name of the file to check.public static boolean isFileBinary(String fileName)
fileName
- Name of the file to check.public static boolean isDataBinary(InputStream is)
public static boolean isFileGzipped(Path path)
public static List<String> execCommandGetOutput(boolean includeError, String... command)
includeError
- Option to set if the returned list includes the standard error
at the end.command
- The command with arguments separated.public static boolean isExecutableOnPath(String execName)
execName
- Name of the executable (ex: vivado)public static boolean isVivadoOnPath()
public static boolean isVivadoCompatible()
public static boolean isVivadoAtLeastVersion(int major, int minor)
major
- The major Vivado version (generally the year)minor
- The minor Vivado versionpublic static String getVivadoVersion()
public static String getVivadoPath()
public static String getOSName()
public static boolean isWindows()
public static void unzipFile(String zipFileName, String destDirectory)
public static FilenameFilter getEDNFilenameFilter()
public static FilenameFilter getDCPFilenameFilter()
public static FilenameFilter getFilenameFilter(String matches)
matches
- Uses the String.matches() to match filename.public static boolean unPackSupportingJarData()
public static Path appendExtension(Path path, String extension)
path
- extension
- public static Path replaceExtension(Path path, String newExtension)
path
- Name of the file to receive the updated extension.newExtension
- The new extension (should include starting period '.')public static String getContainerName(String fileName)
fileName
- Name of the RapidWright data filepublic static String getCurrentDataVersion(String dataFileName)
dataFileName
- Name of the RapidWright data file name
(for example: data/devices/artix7/xa7a100t_db.dat)public static void setOverrideDataFileDownload(boolean value)
public static boolean overrideDataFileDownload()
public static List<Path> getAllFilesWithSuffix(Path root, String suffix)
root
- The root directory from which to start the querysuffix
- The file name extension (or suffix pattern) of the files to getpublic static void blockSystemExitCalls()
SecurityException
in its
place. This method allows for a check to avoid the JVM WARNING message in
Java 17.public static void main(String[] args)
public static Path decompressGZIPFile(Path gzipFile)
gzipFile
- Path to the original gzipped fileFileTools.getDecompressedGZIPFileName(Path)
) or null if the provided
file is not a gzipped file.public static Path compressFileUsingGZIP(Path uncompressedFile)
uncompressedFile
- The path to the uncompressed filepublic static Path getDecompressedGZIPFileName(Path gzipFile)
gzipFile
- The path to the gzipped file.public static Path replaceDir(Path path, Path newDir)