org.homeunix.thecave.moss.util
Class OperatingSystemUtil

java.lang.Object
  extended by org.homeunix.thecave.moss.util.OperatingSystemUtil

public class OperatingSystemUtil
extends java.lang.Object


Constructor Summary
OperatingSystemUtil()
           
 
Method Summary
static java.io.File getHomeDirectory()
           
static java.io.File getLogFile(java.lang.String programName, java.lang.String fileName)
          Returns the user's log folder on the current OS.
static java.io.File getPicturesFolder()
          Return the Pictures folder for the OS.
static java.io.File getProgramsFolder(java.lang.String programName)
          Returns the location of the standard location for programs.
static java.io.File getUserFile(java.lang.String programName, java.lang.String fileName)
          Returns the file with the given name, in the correct user folder for the current OS and given program name.
static java.io.File getUserFolder(java.lang.String programName)
          Returns the user folder for the given operating system.
static boolean isMac()
          Is the program being run on a Macintosh?
static boolean isMacAqua()
          Returns true iff the program is being run on a Mac, and one of either Aqua or Quaqua look and feels are being used.
static java.lang.Boolean isWindows()
          Is the program being run on Windows?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperatingSystemUtil

public OperatingSystemUtil()
Method Detail

isMacAqua

public static boolean isMacAqua()
Returns true iff the program is being run on a Mac, and one of either Aqua or Quaqua look and feels are being used.

Returns:

isMac

public static boolean isMac()
Is the program being run on a Macintosh?

Returns:
true if program is being run on a Mac, false otherwise.

isWindows

public static java.lang.Boolean isWindows()
Is the program being run on Windows?

Returns:
true if program is being run on Windows, false otherwise.

getUserFile

public static java.io.File getUserFile(java.lang.String programName,
                                       java.lang.String fileName)
Returns the file with the given name, in the correct user folder for the current OS and given program name. Does no checking if this is valid, existing, writable, etc.

Parameters:
programName -
fileName -
Returns:

getProgramsFolder

public static java.io.File getProgramsFolder(java.lang.String programName)
Returns the location of the standard location for programs. This is C:\Program Files\Program Name on Windows, /Applications on the Mac, and /usr/bin on Unix.

Parameters:
programName -
Returns:

getUserFolder

public static java.io.File getUserFolder(java.lang.String programName)
Returns the user folder for the given operating system. For Windows, this is Documents and Settings\\user\\Application Data\\Program Name\\. For Mac, this is ~/Library/Application Support/Program Name/. For others (we assume Unix), this is ~/.program_name/.

Parameters:
programName -
fileName -
Returns:

getHomeDirectory

public static java.io.File getHomeDirectory()

getPicturesFolder

public static java.io.File getPicturesFolder()
Return the Pictures folder for the OS. On Windows, it is My Pictures; on Macintosh, it's Pictures, on anything else, it's just the home directory. This does not take into account different locales for the OS.

Returns:

getLogFile

public static java.io.File getLogFile(java.lang.String programName,
                                      java.lang.String fileName)
Returns the user's log folder on the current OS. As this may be related to the program name, we include that as an argument. For Windows, this is C:\\Documents and Settings\\user\\Application Data\\programName\\fileName. For Mac, this is ~/Library/Application Support/programName/fileName. For others, this is ~/.program_name/fileName.

Parameters:
programName -
fileName -
Returns: