# FileOptions

Import: `import com.install4j.api.context.FileOptions;`

```java
public class FileOptions
```

An object that contains options for the installation and uninstallation of a file.
Objects of this class have to be used as parameters for the
`installFile(...)` methods of the `InstallerContext`.


**See also:**

- [InstallerContext.installFile](InstallerContext.md#installfile-file-file-fileoptions)
- [InstallerContext.installFile](InstallerContext.md#installfile-file-file-fileoptions-progressinterface-int-int)

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`getFileTime()`](#getfiletime) | `long` | Returns the file time. |
| [`setFileTime(long)`](#setfiletime-long) | `void` | Sets the file time. |
| [`getMode()`](#getmode) | `String` | Returns the unix access mode. |
| [`setMode(int)`](#setmode-int) | `void` | Sets the unix file mode as an integer. |
| [`setMode(String)`](#setmode-string) | `void` | Sets the unix file mode as an octal string. |
| [`getOverwriteMode()`](#getoverwritemode) | `OverwriteMode` | Returns the overwrite mode. |
| [`setOverwriteMode(OverwriteMode)`](#setoverwritemode-overwritemode) | `void` | Sets the overwrite mode. |
| [`isShared()`](#isshared) | `boolean` | Returns whether the file will be installed as a shared file on Windows. |
| [`setShared(boolean)`](#setshared-boolean) | `void` | Sets whether the file should be installed as shared on Windows. |
| [`getUninstallMode()`](#getuninstallmode) | `UninstallMode` | Returns the uninstallation mode. |
| [`setUninstallMode(UninstallMode)`](#setuninstallmode-uninstallmode) | `void` | Sets whether the file should be uninstalled. |
| [`isDelayIfNecessary()`](#isdelayifnecessary) | `boolean` | Returns whether the operation should be delayed until reboot on Windows if necessary. |
| [`setDelayIfNecessary(boolean)`](#setdelayifnecessary-boolean) | `void` | Sets whether the operation should be delayed until reboot on Windows if necessary. |
| [`toString()`](#tostring) | `String` |  |

### getFileTime()

```java
public long getFileTime()
```

Returns the file time. This is the same time format as in `java.io.File.lastModified()`.


**Returns:** the file time.

### setFileTime(long)

```java
public void setFileTime(long fileTime)
```

Sets the file time. This is the same time format as in `java.io.File.lastModified()`.


**Parameters:**

- `fileTime` — the new file time.

### getMode()

```java
public String getMode()
```

Returns the unix access mode.


**Returns:** the mode as String (e.g. "644")

### setMode(int)

```java
public void setMode(int intMode)
```

Sets the unix file mode as an integer.
For specifying integer file modes, you can use octal numbers by prefixing
a "0".


**Parameters:**

- `intMode` — the mode as an integer (example: 0664).

### setMode(String)

```java
public void setMode(String mode)
```

Sets the unix file mode as an octal string.


**Parameters:**

- `mode` — the mode as an octal string (example: "664").

### getOverwriteMode()

```java
public OverwriteMode getOverwriteMode()
```

Returns the overwrite mode.


**Returns:** one of the OverwriteMode.* constants.

### setOverwriteMode(OverwriteMode)

```java
public void setOverwriteMode(OverwriteMode overwriteMode)
```

Sets the overwrite mode.


**Parameters:**

- `overwriteMode` — one of the OverwriteMode.* constants.

### isShared()

```java
public boolean isShared()
```

Returns whether the file will be installed as a shared file on Windows.


**Returns:** `true` or `false`.

### setShared(boolean)

```java
public void setShared(boolean shared)
```

Sets whether the file should be installed as shared on Windows.


**Parameters:**

- `shared` — `true` or `false`

### getUninstallMode()

```java
public UninstallMode getUninstallMode()
```

Returns the uninstallation mode.


**Returns:** one of the UninstallMode.* constants.

### setUninstallMode(UninstallMode)

```java
public void setUninstallMode(UninstallMode uninstallMode)
```

Sets whether the file should be uninstalled.


**Parameters:**

- `uninstallMode` — one of the UninstallMode.* constants.

### isDelayIfNecessary()

```java
public boolean isDelayIfNecessary()
```

Returns whether the operation should be delayed until reboot on Windows if necessary.


**Returns:** `true` or `false`.

### setDelayIfNecessary(boolean)

```java
public void setDelayIfNecessary(boolean delayIfNecessary)
```

Sets whether the operation should be delayed until reboot on Windows if necessary.


**Parameters:**

- `delayIfNecessary` — `true` or `false`.

### toString()

```java
public String toString()
```

## Constructors

| Signature | Description |
|---|---|
| [`FileOptions()`](#fileoptions) | Initializes a FileOptions instance. |
| [`FileOptions(String, OverwriteMode, boolean)`](#fileoptions-string-overwritemode-boolean) | Initializes a FileOptions instance. |
| [`FileOptions(long)`](#fileoptions-long) | Initializes a FileOptions instance. |
| [`FileOptions(long, OverwriteMode)`](#fileoptions-long-overwritemode) | Initializes a FileOptions instance. |
| [`FileOptions(long, String, OverwriteMode, boolean, UninstallMode)`](#fileoptions-long-string-overwritemode-boolean-uninstallmode) | Initializes a FileOptions instance. |
| [`FileOptions(long, String, OverwriteMode, boolean, boolean, UninstallMode)`](#fileoptions-long-string-overwritemode-boolean-boolean-uninstallmode) | Initializes a FileOptions instance. |
| [`FileOptions(OverwriteMode, UninstallMode)`](#fileoptions-overwritemode-uninstallmode) | Initializes a FileOptions instance. |

### FileOptions()

```java
public FileOptions()
```

Initializes a FileOptions instance. This is the same as calling
[`FileOptions(new Date().getTime(),
DEFAULT_MODE, OverwriteMode.ALWAYS_ASK_EXCEPT_FOR_UPDATE, false, UninstallMode.IF_CREATED)`](FileOptions.md#fileoptions-long-string-overwritemode-boolean-uninstallmode).

### FileOptions(String, OverwriteMode, boolean)

```java
public FileOptions(String mode, OverwriteMode overwriteMode, boolean shared)
```

Initializes a FileOptions instance. This is the same as calling
[`FileOptions(new Date().getTime(),
mode, overwriteMode, shared, UninstallMode.IF_CREATED)`](FileOptions.md#fileoptions-long-string-overwritemode-boolean-uninstallmode).


**Parameters:**

- `mode` — the mode for the destination file (e.g. "644"). This has no effect on Windows.
- `overwriteMode` — how an existing destination file should be handled.
- `shared` — the file will be installed as shared on Windows. This means that a reference counter will
ensure that the file won't be uninstalled if it is also used by another program. This is highly
recommended for files that will be installed in Windows system directories.

### FileOptions(long)

```java
public FileOptions(long fileTime)
```

Initializes a FileOptions instance. This is the same as calling
[`FileOptions(fileTime,
DEFAULT_MODE, OverwriteMode.ALWAYS_ASK_EXCEPT_FOR_UPDATE, false, UninstallMode.IF_CREATED)`](FileOptions.md#fileoptions-long-string-overwritemode-boolean-uninstallmode).


**Parameters:**

- `fileTime` — the "last modified" time the file will be set to.

### FileOptions(long, OverwriteMode)

```java
public FileOptions(long fileTime, OverwriteMode overwriteMode)
```

Initializes a FileOptions instance. This is the same as calling
[`FileOptions(fileTime,
DEFAULT_MODE, overwrite, false, UninstallMode.IF_CREATED)`](FileOptions.md#fileoptions-long-string-overwritemode-boolean-uninstallmode).


**Parameters:**

- `fileTime` — the "last modified" time the file will be set to.
- `overwriteMode` — how an existing destination file should be handled.

### FileOptions(long, String, OverwriteMode, boolean, UninstallMode)

```java
public FileOptions(long fileTime, String mode, OverwriteMode overwriteMode, boolean shared, UninstallMode uninstallMode)
```

Initializes a FileOptions instance.


**Parameters:**

- `fileTime` — the "last modified" time the file will be set to.
- `mode` — the mode for the destination file (e.g. "644"). This has no effect on Windows.
- `overwriteMode` — how an existing destination file should be handled.
- `shared` — the file will be installed as shared on Windows. This means that a reference counter will
ensure that the file won't be uninstalled if it is also used by another program. This is highly
recommended for files that will be installed in Windows system directories.
- `uninstallMode` — the behavior for uninstallation.

### FileOptions(long, String, OverwriteMode, boolean, boolean, UninstallMode)

```java
public FileOptions(long fileTime, String mode, OverwriteMode overwriteMode, boolean shared, boolean delayIfNecessary, UninstallMode uninstallMode)
```

Initializes a FileOptions instance.


**Parameters:**

- `fileTime` — the "last modified" time the file will be set to.
- `mode` — the mode for the destination file (e.g. "644"). This has no effect on Windows.
- `overwriteMode` — how an existing destination file should be handled.
- `shared` — the file will be installed as shared on Windows. This means that a reference counter will
ensure that the file won't be uninstalled if it is also used by another program. This is highly
recommended for files that will be installed in Windows system directories.
- `delayIfNecessary` — whether the operation should be delayed until reboot on Windows if necessary.
- `uninstallMode` — the behavior for uninstallation.

### FileOptions(OverwriteMode, UninstallMode)

```java
public FileOptions(OverwriteMode overwriteMode, UninstallMode uninstallMode)
```

Initializes a FileOptions instance. This is the same as calling
[`FileOptions(new Date().getTime(),
DEFAULT_MODE, overwriteMode, false, uninstallMode)`](FileOptions.md#fileoptions-long-string-overwritemode-boolean-uninstallmode).


**Parameters:**

- `overwriteMode` — how an existing destination file should be handled.
- `uninstallMode` — the behavior for uninstallation.

## Fields

| Field | Type | Description |
|---|---|---|
| [DEFAULT_MODE](#default-mode) | `String` | The default file mode on Unix and macOS ("644"). |

### DEFAULT_MODE

```java
public static final String DEFAULT_MODE = "644"
```

The default file mode on Unix and macOS ("644").

