Reorganized file structure
This commit is contained in:
parent
8b595ef3ce
commit
722d07c321
57 changed files with 431 additions and 614 deletions
29
src/build/Write.go
Normal file
29
src/build/Write.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package build
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/elf"
|
||||
)
|
||||
|
||||
// Write writes the executable file to disk.
|
||||
func Write(filePath string, code []byte, data []byte) error {
|
||||
file, err := os.Create(filePath)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
buffer := bufio.NewWriter(file)
|
||||
executable := elf.New(code, data)
|
||||
executable.Write(buffer)
|
||||
buffer.Flush()
|
||||
err = file.Close()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.Chmod(filePath, 0755)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue