-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embed default resources in the executable
- Loading branch information
Showing
13 changed files
with
282 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package apple2 | ||
|
||
import ( | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
"strings" | ||
|
||
"github.com/ivanizag/apple2/romdumps" | ||
) | ||
|
||
const ( | ||
internalPrefix = "<internal>/" | ||
) | ||
|
||
func loadResource(filename string) []uint8 { | ||
var file io.Reader | ||
if strings.HasPrefix(filename, internalPrefix) { | ||
// load from embedded resource | ||
resource := strings.TrimPrefix(filename, internalPrefix) | ||
resourceFile, err := romdumps.Assets.Open(resource) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer resourceFile.Close() | ||
file = resourceFile | ||
} else { | ||
diskFile, err := os.Open(filename) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer diskFile.Close() | ||
file = diskFile | ||
} | ||
|
||
data, err := ioutil.ReadAll(file) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return data | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// To generate the resources put the files on a "files" subdirectory and run main | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/shurcooL/vfsgen" | ||
) | ||
|
||
func main() { | ||
var cwd, _ = os.Getwd() | ||
templates := http.Dir(filepath.Join(cwd, "files")) | ||
if err := vfsgen.Generate(templates, vfsgen.Options{ | ||
Filename: "../romdumps_vfsdata.go", | ||
PackageName: "romdumps", | ||
VariableName: "Assets", | ||
}); err != nil { | ||
log.Fatalln(err) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.