## 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_Duik_api.jsxinc, line 7386

# Members

Type: `string`

#### # static binAsString

The string representation of the binary file.

View Source DuAEF_Duik_api.jsxinc, line 7397

Type: `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_Duik_api.jsxinc, line 7415

Type: `string`

#### # static fileName

The name of the original file.

View Source DuAEF_Duik_api.jsxinc, line 7406

# 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_Duik_api.jsxinc, line 7632

Returns:
The binary file created, or null if failed
Type: `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_Duik_api.jsxinc, line 7517

Returns:
The `DuBinary` object containing the file as a string
Type: `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_Duik_api.jsxinc, line 7580

Returns:
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.
Type: `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 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");

#### # 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_Duik_api.jsxinc, line 7542

Returns:
The jsxinc file created
Type: `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_Duik_api.jsxinc, line 7454

Returns:
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.
Type: `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.jsxinc
    var 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_Duik_api.jsxinc, line 7490

Returns:
the new jsxinc file.
Type: `File`

#### # toSource() → {string}

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

View Source DuAEF_Duik_api.jsxinc, line 7428

Returns:
The source.
Type: `string`