-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added VersionUtil class and utility method for obtaining file version information #562
Conversation
* version info could be obtained. | ||
*/ | ||
public static int[] getFileVersionNumbers(String filePath) { | ||
IntByReference dwDummy = new IntByReference(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of returning an int[], return a class - e.g.:
public class VersionInfo implements Serializable, Cloneable, Comparable<VersionInfo> {
private static final long serialVersionUID = ...generate it via the IDE...;
private int major = -1;
private int minor = -1;
private int buildNumber = -1;
private int revision = -1;
public VersionInfo() {
super();
}
public VersionInfo(int major, int minor, int buildNumber, int release) {
this.minor/major/build/release = ...respective parameter...
}
public int getMajor/Minor/BuildNumber/Release() {
return ...respective member...
}
public void setMajor/Minor/BuildNumber/Release(int value) {
this..minor/major/build/release = value;
}
@Override
public int hashCode() {
...
}
@Override
public boolean equals(Object o) {
...check if null, this == o and getClass() == o.getClass()...
return compare((VersionInfo) o) == 0;
}
@Override
public int compare(VersionInfo other) {
..check if other is null or this...
...compare major/minor/build/release - in this order...
}
@Override
public VersionInfo clone() {
try {
return getClass().cast(super.clone());
} catch(CloneNotSupportedException e) { // unexpected
throw new RuntimeException("Failed to clone: " + toString(), e);
}
}
@Override
public String toString() {
return getMajor() + "." + getMinor() + "." + getBuildNumber() + "." + getRevision();
}
}
This way one does not need to remember which index in the array is the major/minor/build/revision...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this sound as an option?
- Change the method name to
getFileVersionInfo()
- Return the
VS_FIXEDFILEINFO
that I already have in the function. - Add the following four getters to
VS_FIXEDFILEINFO
:
public int getFileVersionMajor() {
return dwFileVersionMS.intValue() >>> 16;
}
public int getFileVersionMinor() {
return dwFileVersionMS.intValue() & 0xffff;
}
public int getFileVersionRevision() {
return dwFileVersionLS.intValue() >>> 16;
}
public int getFileVersionBuild() {
return dwFileVersionLS.intValue() & 0xffff;
}
This is great. Feel free to address @lgoldstein's minor test comments and please fix that period! (very important :)). |
@dblock, @lgoldstein - feedback should be addressed. |
added VersionUtil class and utility method for obtaining file version information
Merged. |
Motivation: There are new releases of java. Modifications: Upgrade java versions to latest release Result: Use latest versions on the CI
It obtains the 'major', 'minor', 'revision', and 'build' version from a given file.
Added unit test for it - it does not require any new Win32 mappings for Version.dll