install4j API

com.install4j.api.windows
Class WinFileSystem

java.lang.Object
  extended by com.install4j.api.windows.WinFileSystem

public class WinFileSystem
extends java.lang.Object

Collection of static methods to access Microsoft Windows-specific folder locations and to execute native file system operations.

Author:
ej-technologies GmbH

Field Summary
static int FOLDER_APPDATA
          Identifies the file system directory that serves as a common repository for application-specific data.
static int FOLDER_DESKTOP
          Identifies the file system directory used to physically store file objects on the desktop.
static int FOLDER_DOCS
          Identifies the file system directory used to physically store a user's common repository of documents.
static int FOLDER_FAVORITES
          Identifies the file system directory that serves as a common repository for the user's favorite items.
static int FOLDER_FONTS
          Identifies a virtual folder containing fonts.
static int FOLDER_LOCAL_APPDATA
          Identifies the file system directory that serves as a data repository for local applications.
static int FOLDER_PROGRAMS
          Identifies the file system directory that contains the user's program groups.
static int FOLDER_SENDTO
          Identifies the file system directory that contains Send To menu items.
static int FOLDER_STARTMENU
          Identifies the file system directory containing Start menu items.
static int FOLDER_STARTUP
          Identifies the file system directory that corresponds to the user's Startup program group.
static int FOLDER_TEMPLATES
          Identifies the file system directory that serves as a common repository for document templates.
 
Method Summary
static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile)
          Creates a shell link.
static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments)
          Creates a shell link.
static void createStartMenuEntry(InstallerContext context, java.lang.String name, java.io.File destination, java.io.File icon)
          Creates an additional start menu entry if start menu creation is enabled by the installer context.
static java.io.File getCommonFilesDirectory()
          Returns a folder for components that are shared across applications.
static java.io.File getProgramFilesDirectory()
          Returns the program files directory of the current Windows installation.
static java.io.File getSpecialFolder(int folderType, boolean allUsers)
          Returns Windows-specific directories like the start menu or the desktop.
static java.io.File getSystemDirectory()
          Returns the system directory.
static java.io.File getWindowsDirectory()
          Returns the "indows directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOLDER_DESKTOP

public static final int FOLDER_DESKTOP
Identifies the file system directory used to physically store file objects on the desktop. A typical path is C:\Documents and Settings\username\Desktop.

See Also:
Constant Field Values

FOLDER_STARTMENU

public static final int FOLDER_STARTMENU
Identifies the file system directory containing Start menu items. A typical path is C:\Documents and Settings\username\Start Menu.

See Also:
Constant Field Values

FOLDER_PROGRAMS

public static final int FOLDER_PROGRAMS
Identifies the file system directory that contains the user's program groups. The groups are themselves file system directories. A typical path is C:\Documents and Settings\username\Start Menu\Programs.

See Also:
Constant Field Values

FOLDER_STARTUP

public static final int FOLDER_STARTUP
Identifies the file system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Windows NT or starts Windows 95. A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup.

See Also:
Constant Field Values

FOLDER_SENDTO

public static final int FOLDER_SENDTO
Identifies the file system directory that contains Send To menu items. A typical path is C:\Documents and Settings\username\SendTo.

See Also:
Constant Field Values

FOLDER_FONTS

public static final int FOLDER_FONTS
Identifies a virtual folder containing fonts. A typical path is C:\Windows\Fonts.

See Also:
Constant Field Values

FOLDER_APPDATA

public static final int FOLDER_APPDATA
Identifies the file system directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data.

See Also:
Constant Field Values

FOLDER_DOCS

public static final int FOLDER_DOCS
Identifies the file system directory used to physically store a user's common repository of documents. A typical path is C:\Documents and Settings\username\My Documents.

See Also:
Constant Field Values

FOLDER_TEMPLATES

public static final int FOLDER_TEMPLATES
Identifies the file system directory that serves as a common repository for document templates. A typical path is C:\Documents and Settings\username\Templates.

See Also:
Constant Field Values

FOLDER_FAVORITES

public static final int FOLDER_FAVORITES
Identifies the file system directory that serves as a common repository for the user's favorite items. A typical path is C:\Documents and Settings\username\Favorites.

See Also:
Constant Field Values

FOLDER_LOCAL_APPDATA

public static final int FOLDER_LOCAL_APPDATA
Identifies the file system directory that serves as a data repository for local applications. A typical path is C:\Documents and Settings\username\Local Settings\Application Data.

See Also:
Constant Field Values
Method Detail

getSpecialFolder

public static java.io.File getSpecialFolder(int folderType,
                                            boolean allUsers)
Returns Windows-specific directories like the start menu or the desktop.

Parameters:
folderType - specifies the requested folder type. Supply one of the FOLDER_ constants.
allUsers - if this parameter is true and if the current user is in the Administrators group, the method returns the requested folder for all users. Otherwise it returns the folder for the current user.
Returns:
the requested folder location.

getProgramFilesDirectory

public static java.io.File getProgramFilesDirectory()
Returns the program files directory of the current Windows installation. A typical path is C:\Program Files.

Returns:
the program files directory.

getCommonFilesDirectory

public static java.io.File getCommonFilesDirectory()
Returns a folder for components that are shared across applications. A typical path is C:\Program Files\Common. Valid only for Windows NT, Windows 2000, and Windows XP systems.

Returns:
the common files directory.

getWindowsDirectory

public static java.io.File getWindowsDirectory()
Returns the "indows directory. A typical path is C:\Windows.

Returns:
the Windows directory.

getSystemDirectory

public static java.io.File getSystemDirectory()
Returns the system directory. A typical path is C:\Windows\system32

Returns:
the system directory.

createShellLink

public static boolean createShellLink(java.io.File file,
                                      java.io.File shortcutTo,
                                      java.io.File iconFile)
Creates a shell link. Note that Windows might change the link suffix from lnk to pif, if you are linking to a DOS executable or a batch file. This as the same as calling createShellLink(file, shortcutTo, iconFile, null)

Parameters:
file - the shell link that should be created inluding the lnk suffix.
shortcutTo - the file it should link to.
iconFile - an optional icon file. If null is given, the icon of the shortcutTo target will be used.
Returns:
true if successful.

createShellLink

public static boolean createShellLink(java.io.File file,
                                      java.io.File shortcutTo,
                                      java.io.File iconFile,
                                      java.lang.String arguments)
Creates a shell link. Note that Windows might change the link suffix from lnk to pif, if you are linking to a DOS executable or a batch file.

Parameters:
file - the shell link that should be created inluding the lnk suffix.
shortcutTo - the file it should link to.
iconFile - an optional icon file. If null is given, the icon of the shortcutTo target will be used.
arguments - the arguments passed to the target.
Returns:
true if successful.

createStartMenuEntry

public static void createStartMenuEntry(InstallerContext context,
                                        java.lang.String name,
                                        java.io.File destination,
                                        java.io.File icon)
                                 throws java.io.IOException
Creates an additional start menu entry if start menu creation is enabled by the installer context. The entry is placed in the group determined by the context.

Parameters:
context - the InstallerContext you receive in Actions and Screens
name - the name of the menu entry. You can create subfolders with a backslash
destination - the file you want to link to
icon - an optional icon file. If null is given, the icon of the destination will be used.
Throws:
java.io.IOException - if it cannot create the folder for the menu entry

install4j API