aijinhui
2023-10-24 8a87e4226aa802d6a0e3566c66824fedf68e77da
ard-work/src/main/java/com/ruoyi/device/dhsdk/lib/LibraryLoad.java
@@ -1,6 +1,7 @@
package com.ruoyi.device.dhsdk.lib;
import com.ruoyi.device.dhsdk.lib.DynamicParseUtil;
import lombok.extern.slf4j.Slf4j;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
@@ -12,6 +13,7 @@
 * @description 动态库加载
 * @date 2020/11/14
 */
@Slf4j(topic = "dhSdk")
public class LibraryLoad {
  private static final String ARCH_WINDOWS = "win";
  private static final String ARCH_LINUX = "linux";
@@ -74,7 +76,7 @@
    if (!(EXTRACT_PATH.endsWith("/") || EXTRACT_PATH.endsWith("\\"))) {
      path = EXTRACT_PATH + "/";
    }
    System.out.println("load library: " + path + fullName);
    log.debug("load library: " + path + fullName);
    return path + fullName;
  }
@@ -85,7 +87,7 @@
   * @return
   */
  private static String extractLibrary(String libName) {
    return extractLibrary("", libName);
    return extractLibrary("/lib", libName);
  }
  /**
@@ -119,6 +121,13 @@
      }
      extractedLibFile = new File(nativeTempDir + libFullName);
      reader = new BufferedInputStream(in);
            // 检查文件夹是否存在,如果不存在则创建
            File parentDir = extractedLibFile.getParentFile();
            if (!parentDir.exists()) {
                parentDir.mkdirs();
            }
      writer = new FileOutputStream(extractedLibFile);
      byte[] buffer = new byte[1024];
      while (true) {
@@ -130,7 +139,7 @@
      writer.close();
      in.close();
    } catch (Exception e) {
      //System.out.println("dynamic file[ "+ fileName+ " ] not found in project.please ensure you need this library.");
           log.error("dynamic file[ " + fileName + " ] not found in project.please ensure you need this library.");
    }
    return extractedLibFile != null ? extractedLibFile.getAbsolutePath() : "";
  }