FileOptions (install4j API)
Description: declaration: package: com.install4j.api.context, class: FileOptions

Package com.install4j.api.context

# Class FileOptions

java.lang.Object
com.install4j.api.context.FileOptions

public class FileOptions extends Object
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(java.io.File, java.io.File, FileOptions)`
  - `InstallerContext.installFile(java.io.File, java.io.File, FileOptions, ProgressInterface, int, int)`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_MODE`
  The default file mode on Unix and macOS ("644").

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FileOptions()`
  Initializes a FileOptions instance.
  `FileOptions(long fileTime)`
  Initializes a FileOptions instance.
  `FileOptions(long fileTime, OverwriteMode overwriteMode)`
  Initializes a FileOptions instance.
  `FileOptions(long fileTime, String mode, OverwriteMode overwriteMode, boolean shared, boolean delayIfNecessary, UninstallMode uninstallMode)`
  Initializes a FileOptions instance.
  `FileOptions(long fileTime, String mode, OverwriteMode overwriteMode, boolean shared, UninstallMode uninstallMode)`
  Initializes a FileOptions instance.
  `FileOptions(OverwriteMode overwriteMode, UninstallMode uninstallMode)`
  Initializes a FileOptions instance.
  `FileOptions(String mode, OverwriteMode overwriteMode, boolean shared)`
  Initializes a FileOptions instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getFileTime()`
  Returns the file time.
  `String`
  `getMode()`
  Returns the unix access mode.
  `OverwriteMode`
  `getOverwriteMode()`
  Returns the overwrite mode.
  `UninstallMode`
  `getUninstallMode()`
  Returns the uninstallation mode.
  `boolean`
  `isDelayIfNecessary()`
  Returns whether the operation should be delayed until reboot on Windows if necessary.
  `boolean`
  `isShared()`
  Returns whether the file will be installed as a shared file on Windows.
  `void`
  `setDelayIfNecessary(boolean delayIfNecessary)`
  Sets whether the operation should be delayed until reboot on Windows if necessary.
  `void`
  `setFileTime(long fileTime)`
  Sets the file time.
  `void`
  `setMode(int intMode)`
  Sets the unix file mode as an integer.
  `void`
  `setMode(String mode)`
  Sets the unix file mode as an octal string.
  `void`
  `setOverwriteMode(OverwriteMode overwriteMode)`
  Sets the overwrite mode.
  `void`
  `setShared(boolean shared)`
  Sets whether the file should be installed as shared on Windows.
  `void`
  `setUninstallMode(UninstallMode uninstallMode)`
  Sets whether the file should be uninstalled.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_MODE

    public static final String DEFAULT_MODE
    The default file mode on Unix and macOS ("644").
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### FileOptions

    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

    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)`.
    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

    public FileOptions(long fileTime)
    Initializes a FileOptions instance. This is the same as calling `FileOptions(fileTime, DEFAULT_MODE, OVERWRITE_ALWAYS_ASK, false, UninstallMode.IF_CREATED)`.
    Parameters:
      `fileTime` - the "last modified" time the file will be set to.

  - ### FileOptions

    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)`.
    Parameters:
      `fileTime` - the "last modified" time the file will be set to.
      `overwriteMode` - how an existing destination file should be handled.

  - ### FileOptions

    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

    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

    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)`.
    Parameters:
      `overwriteMode` - how an existing destination file should be handled.
      `uninstallMode` - the behavior for uninstallation.

- ## Method Details

  - ### getFileTime

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

  - ### setFileTime

    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

    public String getMode()
    Returns the unix access mode.
    Returns:
      the mode as String (e.g. "644")

  - ### setMode

    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

    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

    public OverwriteMode getOverwriteMode()
    Returns the overwrite mode.
    Returns:
      one of the OverwriteMode.* constants.

  - ### setOverwriteMode

    public void setOverwriteMode(OverwriteMode overwriteMode)
    Sets the overwrite mode.
    Parameters:
      `overwriteMode` - one of the OverwriteMode.* constants.

  - ### isShared

    public boolean isShared()
    Returns whether the file will be installed as a shared file on Windows.
    Returns:
      `true` or `false`.

  - ### setShared

    public void setShared(boolean shared)
    Sets whether the file should be installed as shared on Windows.
    Parameters:
      `shared` - `true` or `false`

  - ### getUninstallMode

    public UninstallMode getUninstallMode()
    Returns the uninstallation mode.
    Returns:
      one of the UninstallMode.* constants.

  - ### setUninstallMode

    public void setUninstallMode(UninstallMode uninstallMode)
    Sets whether the file should be uninstalled.
    Parameters:
      `uninstallMode` - one of the UninstallMode.* constants.

  - ### isDelayIfNecessary

    public boolean isDelayIfNecessary()
    Returns whether the operation should be delayed until reboot on Windows if necessary.
    Returns:
      `true` or `false`.

  - ### setDelayIfNecessary

    public void setDelayIfNecessary(boolean delayIfNecessary)
    Sets whether the operation should be delayed until reboot on Windows if necessary.
    Parameters:
      `delayIfNecessary` - `true` or `false`.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`