chore:remove folder
This commit is contained in:
@@ -2,6 +2,9 @@ package parse
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -145,8 +148,7 @@ func (p *SymbolProcessor) visitTop(cursor, parent clang.Cursor) clang.ChildVisit
|
||||
clangutils.VisitChildren(cursor, p.visitTop)
|
||||
case clang.CursorCXXMethod, clang.CursorFunctionDecl, clang.CursorConstructor, clang.CursorDestructor:
|
||||
loc := cursor.Location()
|
||||
var file clang.File
|
||||
loc.SpellingLocation(&file, nil, nil, nil)
|
||||
file, _, _, _ := clangutils.GetLocation(loc)
|
||||
filename := file.FileName()
|
||||
defer filename.Dispose()
|
||||
|
||||
@@ -185,3 +187,37 @@ func ParseHeaderFile(files []string, Prefixes []string, isCpp bool, isTemp bool)
|
||||
index.Dispose()
|
||||
return processer.SymbolMap, nil
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user