createParserBinary creates a temporary file containing the driver_ast_parser binary, and returns the path to it.
()
| 40 | // createParserBinary creates a temporary file containing the driver_ast_parser |
| 41 | // binary, and returns the path to it. |
| 42 | func createParserBinary() (string, error) { |
| 43 | tmpFile, err := os.CreateTemp(os.TempDir(), "driver_ast_parser_*") |
| 44 | if err != nil { |
| 45 | return "", fmt.Errorf("failed to create temporary file: %w", err) |
| 46 | } |
| 47 | defer func() { |
| 48 | if err := tmpFile.Close(); err != nil { |
| 49 | log.Warningf("failed to close driver_ast_parser binary: %w", err) |
| 50 | } |
| 51 | }() |
| 52 | |
| 53 | if _, err := tmpFile.Write(driverParserBinary); err != nil { |
| 54 | return "", fmt.Errorf("failed to write to temporary file: %w", err) |
| 55 | } |
| 56 | |
| 57 | if err := tmpFile.Chmod(0500); err != nil { |
| 58 | return "", fmt.Errorf("failed to make file executable: %w", err) |
| 59 | } |
| 60 | |
| 61 | return tmpFile.Name(), nil |
| 62 | } |
| 63 | |
| 64 | // Main is the main function for the NVIDIA driver differ. |
| 65 | func Main() error { |