mirror of
https://github.com/github/codeql.git
synced 2026-01-29 22:32:58 +01:00
Add FileFor utility function for trap files
This commit is contained in:
@@ -26,14 +26,22 @@ type Writer struct {
|
||||
Package *packages.Package
|
||||
}
|
||||
|
||||
func FileFor(path string) (string, error) {
|
||||
trapFolder, err := trapFolder()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return filepath.Join(trapFolder, srcarchive.AppendablePath(path)+".trap.gz"), nil
|
||||
}
|
||||
|
||||
// NewWriter creates a TRAP file for the given path and returns a writer for
|
||||
// writing to it
|
||||
func NewWriter(path string, pkg *packages.Package) (*Writer, error) {
|
||||
trapFolder, err := trapFolder()
|
||||
trapFilePath, err := FileFor(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
trapFilePath := filepath.Join(trapFolder, srcarchive.AppendablePath(path)+".trap.gz")
|
||||
trapFileDir := filepath.Dir(trapFilePath)
|
||||
err = os.MkdirAll(trapFileDir, 0755)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user