Class

DuBinary

DuBinary(binAsString, fileName, categoryopt)

Represents a binary file as a string and a filename.
Constructor

# new DuBinary(binAsString, fileName, categoryopt)

Constructs a new string representation of a binary file
Parameters:
Name Type Attributes 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".

View Source DuAEF_DuGR_api.jsxinc, line 7370

Members

string

# static binAsString

The string representation of the binary file.

View Source DuAEF_DuGR_api.jsxinc, line 7381

string

# static category

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

View Source DuAEF_DuGR_api.jsxinc, line 7399

string

# static fileName

The name of the original file.

View Source DuAEF_DuGR_api.jsxinc, line 7390

Methods

# static convertToBinaryFile(jsFile, outputFileNameopt) → {File}

Converts a JS file to a binary file
Parameters:
Name Type Attributes Default Description
jsFile File The JS file to convert
outputFileName string <optional>
DuFolder.duesfData/category/binaryfilename The output filename.
Deprecated:
  • Yes

View Source DuAEF_DuGR_api.jsxinc, line 7616

The binary file created, or null if failed
File
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.

# static fromFile(file, categoryopt) → {DuBinary}

Creates a DuBinary object from an existing file
Parameters:
Name Type Attributes 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".

View Source DuAEF_DuGR_api.jsxinc, line 7501

The DuBinary object containing the file as a string
DuBinary

# static toFile(DuBinary, outputFileNameopt, onlyAtFirstRunopt) → {File|null}

Creates a file from a DuBinary object representation.
Parameters:
Name Type Attributes 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 <optional>
DuFolder.duesfData/DuAEF/scriptName/category/binaryfilename The output filename.
onlyAtFirstRun boolean <optional>
true 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

View Source DuAEF_DuGR_api.jsxinc, line 7564

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.
File | null
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 filevar 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.jsxincvar presetFile = DuBinary.toFile(preset,"C:/test/test_preset.ffx");presetFile.fsName; // C:\test\test_preset.exe");

# static toJsxincFile(file, categoryopt, outputFilePathopt, varNameopt) → {File}

Converts a file to a jsxinc file
Parameters:
Name Type Attributes 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 <optional>
Same folder, same name with .json extension The file name for the output.
varName string <optional>
File name without extension The name of the variable used to store the javascript object.

View Source DuAEF_DuGR_api.jsxinc, line 7526

The jsxinc file created
File

# toFile(outputFileNameopt, onlyAtFirstRunopt) → {File|null}

Writes the file.
Parameters:
Name Type Attributes Default Description
outputFileName string <optional>
DuFolder.duesfData/category/binaryfilename The output filename.
onlyAtFirstRun boolean <optional>
true 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).

View Source DuAEF_DuGR_api.jsxinc, line 7438

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.
File | null
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.jsxincvar presetFile = preset.extract("C:/test/test_preset.ffx");presetFile.fsName; // C:\test\test_preset.exe");

# toJsxincFile(outputFilePath, varNameopt) → {File}

Writes the DuBinary to a jsxinc file
Parameters:
Name Type Attributes Default Description
outputFilePath string The file path for the output.
varName any <optional>
File name without extension The name of the variable used to store the javascript object.

View Source DuAEF_DuGR_api.jsxinc, line 7474

the new jsxinc file.
File

# toSource() → {string}

Returns a string representation of the DuBinary which can be written in a jsxinc file.

View Source DuAEF_DuGR_api.jsxinc, line 7412

The source.
string