pputil

package
v0.9.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHeaderFile

func IsHeaderFile(name string) bool

IsHeaderFile checks if the given file name has a header file extension.

func ListFiles

func ListFiles(dir string, recursive bool) iter.Seq2[FileEntry, error]

ListFiles returns a sequence of files in the specified directory. If recursive is true, it includes files in subdirectories as well.

func ListIncludes

func ListIncludes(headerFile string, includeDirs []string) (includeFiles iter.Seq2[string, bool], err error)

ListIncludes lists the include files for the specified header file. It returns a sequence of include file paths and a boolean indicating whether the file was found. The include file path is the resolved path when ok is true, and the raw include filename otherwise.

func LoadIncludes

func LoadIncludes(headerFile string) (includes iter.Seq[Include], err error)

LoadIncludes loads the include directives from the specified header file. It returns a sequence of Include objects.

It parses the file in a single pass, correctly handling `#include` directives with spaces or tabs between `#` and `include`, and ignoring any `#include` occurrences found within comments or string/character literals.

func TopHeaders

func TopHeaders(headerDir string, recursive, rel bool, includeDirs []string) (topHeaders []string, err error)

TopHeaders returns the top-level header files in the specified directory.

Types

type FileEntry

type FileEntry struct {
	Path string
	os.DirEntry
}

FileEntry represents a file entry in a directory.

type Include

type Include struct {
	Filename string
	Quote    bool
}

Include represents a C/C++ include directive.

func (*Include) Search

func (p *Include) Search(workDir string, searchDirs []string) (found string, ok bool)

Search searches for the include file in the specified directories. Note: `found` is the resolved path only when ok is true, and the raw include name otherwise.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL