feisty meow concerns codebase  2.140
VersionManager.java
Go to the documentation of this file.
1 package org.gffs.version;
2 
3 import java.io.File;
4 import java.io.IOException;
5 
6 import org.gffs.application.ProgramTools;
7 
8 public class VersionManager
9 {
10  static private final String VERSION_FILENAME = "current.version";
11 
12  private Version _currentVersion;
13  private File _versionFile;
14 
15  public VersionManager()
16  {
17  _versionFile = new File(ProgramTools.getInstallationDirectory(), VERSION_FILENAME);
18  _currentVersion = null;
19  }
20 
21  public Version getCurrentVersion() throws IOException
22  {
23  if (_currentVersion == null) {
24  // we go with the installer scheme to start with, where there's a current.version in the
25  // top-level.
26  if (!_versionFile.exists()) {
27  // try failing over to the source code's version of the file inside the installer
28  // directory.
29  _versionFile = new File(ProgramTools.getInstallationDirectory(), "installer/" + VERSION_FILENAME);
30  if (!_versionFile.exists()) {
31  _currentVersion = Version.EMPTY_VERSION;
32  }
33  }
34  if (_versionFile.exists()) {
35  _currentVersion = new Version(_versionFile);
36  }
37  }
38 
39  return _currentVersion;
40  }
41 }
static String getInstallationDirectory()
static Version EMPTY_VERSION
Definition: Version.java:99