Skip to content

Commit

Permalink
update liblcl init
Browse files Browse the repository at this point in the history
  • Loading branch information
sxmxta committed Jun 22, 2023
1 parent f31ac61 commit 59a81a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
19 changes: 9 additions & 10 deletions energy/inits/inits.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/energye/golcl/pkgs/libname"
"github.com/energye/golcl/pkgs/macapp"
"io"
"io/fs"
"os"
"path"
"runtime"
Expand Down Expand Up @@ -71,18 +70,18 @@ func Init(libs *embed.FS, resources *embed.FS) {
initAll()
}

// 释放文件
// 如果liblcl动态库内置到EXE中, 在EXE中把liblcl释放到out目录
func releaseLib(fsPath, out string) {
if emfs.GetLibsFS() != nil {
var err error
var fsFile fs.File
var file *os.File
file, err = os.OpenFile(out, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
panic(err)
}
defer file.Close()
fsFile, err = emfs.GetLibsFS().Open(fsPath)
var fsFile, err = emfs.GetLibsFS().Open(fsPath)
if err == nil {
var file *os.File
file, err = os.OpenFile(out, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
panic(err)
}
defer file.Close()
defer fsFile.Close()
var n int
//读取数据
Expand Down
9 changes: 7 additions & 2 deletions pkgs/libname/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func GetDLLName() string {
return libName
}

// LibPath
// 获取 liblcl 动态库目录
// 优先级
// 1. 当前目录 > 用户目录 > LCL_HOME > ENERGY_HOME
// 推荐[当前目录]或指定[ENERGY_HOME]环境变量
func LibPath() string {
var dllName = GetDLLName()
//当前目录
Expand All @@ -49,12 +54,12 @@ func LibPath() string {
if tools.IsExist(homePathLibName) {
return homePathLibName
}
//环境变量 LCL_HOME
//环境变量 LCL_HOME - 为区分单独使用GO LCL
var envPathLibName = path.Join(os.Getenv("LCL_HOME"), dllName)
if tools.IsExist(envPathLibName) {
return envPathLibName
}
//环境变量 ENERGY_HOME
//环境变量 ENERGY_HOME - 在使用Energy框架
var energyPathLibName = path.Join(os.Getenv("ENERGY_HOME"), dllName)
if tools.IsExist(energyPathLibName) {
return energyPathLibName
Expand Down

0 comments on commit 59a81a3

Please sign in to comment.