Files
llgo/chore/_xtool/llcppsymg/header/header.go
luoliwoshang 944133de6e llcppsymg:symbol generate test
llcppsymg:symbo test

llcppsymg:exist symb file test

llcppsymg:GenSymbolTabledata

llcppsymg:GenSymbolTableData test

llcppsymg:full symg operation test
2024-10-21 18:48:56 +08:00

43 lines
890 B
Go

package header
import (
"fmt"
"os"
"path/filepath"
"strings"
)
func GenHeaderFilePath(cflags string, files []string) ([]string, error) {
prefixPath := strings.TrimPrefix(cflags, "-I")
var validPaths []string
var errs []string
for _, file := range files {
if file == "" {
continue
}
fullPath := filepath.Join(prefixPath, file)
if f, err := os.Open(fullPath); err != nil {
if os.IsNotExist(err) {
errs = append(errs, fmt.Sprintf("file not found: %s", file))
} else {
errs = append(errs, fmt.Sprintf("error accessing file %s: %v", file, err))
}
} else {
f.Close()
validPaths = append(validPaths, fullPath)
}
}
if len(validPaths) == 0 && len(errs) == 0 {
return nil, fmt.Errorf("no valid header files")
}
if len(errs) > 0 {
return validPaths, fmt.Errorf("some files not found or inaccessible: %v", errs)
}
return validPaths, nil
}