Class OsSupport

java.lang.Object
org.ek9lang.core.OsSupport
All Implemented Interfaces:
Serializable

public final class OsSupport extends Object implements Serializable
Operating System support and generic stuff for directories and files.
See Also:
  • Constructor Details

    • OsSupport

      public OsSupport()
    • OsSupport

      public OsSupport(boolean testStubMode)
      Used as and when you want to use a stub for testing. You don't always want to create or access the actual users home directory or current working directory.
  • Method Details

    • numberOfProcessors

      public static int numberOfProcessors()
    • isInStubMode

      public boolean isInStubMode()
      Is this configured to be in stub mode.
    • getPid

      public long getPid()
      Provides the current process id of this running application.
    • makeDirectoryIfNotExists

      public void makeDirectoryIfNotExists(File directory)
      Create directory if it does not exist or exception if failed.
    • getTempDirectory

      public String getTempDirectory()
      Get name of temporary directory.
    • getUsersHomeDirectory

      public String getUsersHomeDirectory()
      Get the users home directory.
    • getCurrentWorkingDirectory

      public String getCurrentWorkingDirectory()
      Get current working directory for this running process.
    • getNumberOfProcessors

      public int getNumberOfProcessors()
      How many CPU's/Core reported.
    • getFileNameWithoutPath

      public String getFileNameWithoutPath(String fileNameWithPath)
      Extract just the final part of a file name.
    • isFileReadable

      public boolean isFileReadable(String fileName)
    • isFileReadable

      public boolean isFileReadable(File file)
    • getFileContent

      public Optional<String> getFileContent(File file)
      Load up a file into a String. Option empty if not possible to load.
    • isDirectoryReadable

      public boolean isDirectoryReadable(String directoryName)
    • isDirectoryReadable

      public boolean isDirectoryReadable(File directory)
    • isDirectoryWritable

      public boolean isDirectoryWritable(String directoryName)
    • isDirectoryWritable

      public boolean isDirectoryWritable(File directory)
    • getFilesFromDirectories

      public List<File> getFilesFromDirectories(Collection<File> inDirectories, String fileSuffix)
      Get List of all the files in a set of directories with a particular suffix.
    • getDirectoriesInDirectory

      public List<File> getDirectoriesInDirectory(File inDirectory, String excludeStartingWith)
      Get files in a particular directory, but not if they start with a prefix.
    • getFilesRecursivelyFrom

      public List<File> getFilesRecursivelyFrom(File inDirectory, Glob searchCondition)
      Search down a directory structure matching a 'Glob".
    • getFilesRecursivelyFrom

      public List<File> getFilesRecursivelyFrom(File inDirectory)
      Get all files down a directory structure.
    • getFilesFromDirectory

      public Collection<File> getFilesFromDirectory(File inDirectory, String fileSuffix)
      Get all files in a directory with a specific suffix.
    • getAllSubdirectories

      public Collection<File> getAllSubdirectories(String directoryRoot)
      Get all subdirectories from a root directory.