Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
SigarLoader.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.corelibs;
20 
21 import com.sun.javafx.PlatformUtil;
22 import org.hyperic.sigar.Sigar;
23 import org.openide.util.NbBundle;
24 
30 public class SigarLoader {
31 
32  private static volatile Sigar sigar;
33 
34  static {
35  //bypass the process of validation/loading of the library by sigar jar
36  System.setProperty("org.hyperic.sigar.path", "-");
37  //System.setProperty(org.hyperic.sigar.SigarLoader.PROP_SIGAR_JAR_NAME, "sigar-1.6.4.jar");
38  }
39 
40  public static Sigar getSigar() {
41  if (sigar == null) {
42  synchronized (SigarLoader.class) {
43  if (sigar == null) {
44  try {
45  //rely on netbeans / jna to locate the lib variation for architecture/OS
46  if (PlatformUtil.isWindows()) {
47  System.loadLibrary("libsigar"); //NON-NLS
48  } else {
49  System.loadLibrary("sigar"); //NON-NLS
50  }
51  sigar = new Sigar();
52  sigar.enableLogging(false); //forces a test
53 
54  } catch (UnsatisfiedLinkError ex) {
55  String msg = NbBundle.getMessage(SigarLoader.class, "SigarLoader.linkErr.msg");
56  System.out.println(msg + ex.toString());
57  } catch (Exception ex) {
58  String msg = NbBundle.getMessage(SigarLoader.class, "SigarLoader.linkErr.msg");
59  System.out.println(msg + ex.toString());
60  }
61  }
62  }
63  }
64 
65  return sigar;
66  }
67 }

Copyright © 2012-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.