-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request oshi#7 from ptitvert/master
Added Mac OS X support
- Loading branch information
Showing
13 changed files
with
595 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
language: java | ||
os: | ||
- osx | ||
- linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* | ||
*/ | ||
package oshi; | ||
|
||
/** | ||
* @author alessandro[at]perucchi[dot]org | ||
*/ | ||
|
||
public enum PlatformEnum { | ||
WINDOWS, LINUX, MACOSX, UNKNOWN; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/oshi/software/os/mac/MacHardwareAbstractionLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* | ||
*/ | ||
package oshi.software.os.mac; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import oshi.hardware.HardwareAbstractionLayer; | ||
import oshi.hardware.Memory; | ||
import oshi.hardware.Processor; | ||
import oshi.software.os.mac.local.CentralProcessor; | ||
import oshi.software.os.mac.local.GlobalMemory; | ||
import oshi.util.ExecutingCommand; | ||
|
||
/** | ||
* @author alessandro[at]perucchi[dot]org | ||
*/ | ||
|
||
public class MacHardwareAbstractionLayer implements HardwareAbstractionLayer { | ||
|
||
private Processor[] _processors; | ||
private Memory _memory; | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see oshi.hardware.HardwareAbstractionLayer#getProcessors() | ||
*/ | ||
public Processor[] getProcessors() { | ||
if (_processors == null) { | ||
List<Processor> processors = new ArrayList<Processor>(); | ||
int nbCPU = new Integer( | ||
ExecutingCommand.getFirstAnswer("sysctl -n hw.availcpu")); | ||
for (int i = 0; i < nbCPU; i++) | ||
processors.add(new CentralProcessor()); | ||
|
||
_processors = processors.toArray(new Processor[0]); | ||
} | ||
return _processors; | ||
|
||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see oshi.hardware.HardwareAbstractionLayer#getMemory() | ||
*/ | ||
public Memory getMemory() { | ||
if (_memory == null) { | ||
_memory = new GlobalMemory(); | ||
} | ||
return _memory; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/oshi/software/os/mac/MacOperatingSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* | ||
*/ | ||
package oshi.software.os.mac; | ||
|
||
import oshi.software.os.OperatingSystem; | ||
import oshi.software.os.OperatingSystemVersion; | ||
import oshi.software.os.mac.local.OSVersionInfoEx; | ||
import oshi.util.ExecutingCommand; | ||
|
||
/** | ||
* @author alessandro[at]perucchi[dot]org | ||
*/ | ||
|
||
public class MacOperatingSystem implements OperatingSystem { | ||
private String _family; | ||
|
||
private OperatingSystemVersion _version = null; | ||
|
||
public OperatingSystemVersion getVersion() { | ||
if (_version == null) { | ||
_version = new OSVersionInfoEx(); | ||
} | ||
return _version; | ||
} | ||
|
||
public String getFamily() { | ||
if (_family == null) | ||
_family = ExecutingCommand.getFirstAnswer("sw_vers -productName"); | ||
|
||
return _family; | ||
} | ||
|
||
public String getManufacturer() { | ||
return "Apple"; | ||
} | ||
|
||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(getManufacturer()); | ||
sb.append(" "); | ||
sb.append(getFamily()); | ||
sb.append(" "); | ||
sb.append(getVersion().toString()); | ||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.