Class: DuBinary

DuBinary

Represents a binary file as a string and a filename.

new DuBinary(binAsString, fileName, category)

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6411
Constructs a new string representation of a binary file
Name Type Default Description
binAsString string The string representation.
fileName string The name of the original file.
category string '' optional A Category for the file, will be used as a subfolder to extract files. Can have subcategories like "category/subcategory".

Members

staticDuBinary.binAsStringstring

The string representation of the binary file.

staticDuBinary.categorystring

A Category for the file, will be used as a subfolder to extract files. Can have subcategories like "category/subcategory".

staticDuBinary.fileNamestring

The name of the original file.

Methods

staticDuBinary.convertToBinaryFile(jsFile, outputFileName){File}

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6655
Converts a JS file to a binary file
Name Type Default Description
jsFile File The JS file to convert
outputFileName string DuFolder.duesfData/category/binaryfilename optional The output filename.
Deprecated
  • Yes
Returns:
Type Description
File The binary file created, or null if failed
Example
//If you don't want to include the file in the script. (Add a # before the include word)
var stringFile = new File("C:\test\image.jpg.jsxinc");
var jpgFile = DuBinary.convertToBinaryFile(stringFile);
// Warning, this method uses `$.eval()` which is a bad security issue.
// Do not use this method for anything else than debugging and testing.

staticDuBinary.fromFile(file, category){DuBinary}

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6541
Creates a DuBinary object from an existing file
Name Type Description
file File The File to convert
category string optional A Category for the file, will be used as a subfolder to extract files. Can have subcategories like "category/subcategory".
Returns:
Type Description
DuBinary The DuBinary object containing the file as a string

staticDuBinary.toFile(DuBinary, outputFileName, onlyAtFirstRun){File|null}

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6603
Creates a file from a DuBinary object representation.
Name Type Default Description
DuBinary DuBinary The DuBinary object containing the string representation.
This object will be replaced by the File object created.
If a file object is provided (the file has already been extracted), does nothing.
outputFileName string DuFolder.duesfData/DuAEF/scriptName/category/binaryfilename optional The output filename.
onlyAtFirstRun boolean true optional Does not extract the file if it already exists and this is not the first time this version of the script is being used.
The file will be extracted only if the script is new or has just been updated (the version changed).
Deprecated
  • Yes
Returns:
Type Description
File | null The file created, null if the file could not be written.
If the file is not written, check user permissions, and check if the file and network access preference is checked.
Examples
//First, include the text representation of the file (Add a # before the include word)
include executable.exe.jsxinc
// Now, a variable called `executable` (the original file name without extension) is available, you can pass this object to the `DuBinary.toFile()` method to extract it and get an ExtendScript File object representation of it.
// Note: This object is an instance of a `DuBinary` class, which contains all information and a string representation of the original binary file
var execFile = DuBinary.toFile(executable);
//Now, the file exists in the file system, and execFile is an ExtendScript File object.
// The `DuBinary.toFile()` method extracts the file to the Application Data folder by default.
execFile.fsName; // C:\users\duduf\appData\Roaming\DuAEF\icon.png (Example on Windows)
//You can specify the output file name. (Add a # before the include word)
include preset.ffx.jsxinc
var presetFile = DuBinary.toFile(preset,"C:/test/test_preset.ffx");
presetFile.fsName; // C:\test\test_preset.exe");

staticDuBinary.toJsxincFile(file, category, outputFilePath, varName){File}

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6566
Converts a file to a jsxinc file
Name Type Default Description
file File The binary file to convert
category string optional A Category for the file, will be used as a subfolder to extract files. Can have subcategories like "category/subcategory". Default is the name of the folder containing the file.
outputFilePath string Same folder, same name with .json extension optional The file name for the output.
varName string File name without extension optional The name of the variable used to store the javascript object.
Returns:
Type Description
File The jsxinc file created

toFile(outputFileName, onlyAtFirstRun){File|null}

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6478
Writes the file.
Name Type Default Description
outputFileName string DuFolder.duesfData/category/binaryfilename optional The output filename.
onlyAtFirstRun boolean true optional Does not extract the file if it already exists and this is not the first time this version of the script is being used.
The file will be extracted only if the script is new or has just been updated (the version changed).
Returns:
Type Description
File | null The file created, null if the file could not be written.
If the file is not written, check user permissions, and check if the file and network access preference is checked.
Examples
//First, include the text representation of the file (Add a # before the include word)
include executable.exe.jsxinc
// Now, a variable called `executable` (the original file name without extension) is available, it's an instance of DuBinary.
var execFile = executable.extract();
//Now, the file exists in the file system, and execFile is an ExtendScript File object.
// The `DuBinary.extract()` method extracts the file to the Application Data folder by default.
execFile.fsName; // C:\users\duduf\appData\Roaming\RxMaboratory\AdobeScripts\DuESF\icon.png (Example on Windows)
//You can specify the output file name. (Add a # before the include word)
include preset.ffx.jsxinc
var presetFile = preset.extract("C:/test/test_preset.ffx");
presetFile.fsName; // C:\test\test_preset.exe");

toJsxincFile(outputFilePath, varName){File}

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6514
Writes the DuBinary to a jsxinc file
Name Type Default Description
outputFilePath string The file path for the output.
varName any File name without extension optional The name of the variable used to store the javascript object.
Returns:
Type Description
File the new jsxinc file.

toSource(){string}

D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 6452
Returns a string representation of the DuBinary which can be written in a jsxinc file.
Returns:
Type Description
string The source.