Created
May 21, 2025 15:33
-
-
Save scapegoat-0001/6620b4a4efba976d4fbff1e14112db44 to your computer and use it in GitHub Desktop.
Convert OpenIV mods into Onigiri format
This file contains hidden or 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
package main | |
import ( | |
"encoding/xml" | |
"fmt" | |
"io" | |
"os" | |
"strings" | |
) | |
type Archive struct { | |
XMLName xml.Name `xml:"archive"` | |
Sources []Source `xml:"add"` | |
} | |
type Source struct { | |
XMLName xml.Name `xml:"add"` | |
Source string `xml:"source,attr"` | |
Target string `xml:",chardata"` | |
} | |
func main() { | |
xmlFile, err := os.Open("assembly.xml") | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
defer xmlFile.Close() | |
if _, err := os.Stat("onigiri"); os.IsNotExist(err) { | |
os.Mkdir("onigiri", 0755) | |
} | |
decoder := xml.NewDecoder(xmlFile) | |
for { | |
token, err := decoder.Token() | |
if err != nil { | |
fmt.Println(err) | |
} | |
switch se := token.(type) { | |
case xml.StartElement: | |
if se.Name.Local == "archive" { | |
var archive Archive | |
if err := decoder.DecodeElement(&archive, &se); err != nil { | |
fmt.Println(err) | |
continue | |
} | |
for _, source := range archive.Sources { | |
sourceFile := "content\\" + strings.TrimSpace(source.Source) | |
sourceTarget := "onigiri\\" + strings.TrimLeft(strings.TrimSpace(source.Target), "\\") | |
fmt.Printf("Source: %s\n", sourceFile) | |
fmt.Printf("Target: %s\n", sourceTarget) | |
sourceFileStat, err := os.Stat(sourceFile) | |
if err != nil { | |
fmt.Println(err) | |
fmt.Println() | |
continue | |
} | |
if !sourceFileStat.Mode().IsRegular() { | |
fmt.Printf("%s is not a regular file\n", sourceFile) | |
continue | |
} | |
sourceFileFile, err := os.Open(sourceFile) | |
if err != nil { | |
fmt.Println(err) | |
fmt.Println() | |
continue | |
} | |
defer sourceFileFile.Close() | |
sourceTargetDir := sourceTarget[:strings.LastIndex(sourceTarget, "\\")] | |
if _, err := os.Stat(sourceTargetDir); os.IsNotExist(err) { | |
os.MkdirAll(sourceTargetDir, 0755) | |
} | |
targetFile, err := os.Create(sourceTarget) | |
if err != nil { | |
fmt.Println(err) | |
fmt.Println() | |
continue | |
} | |
defer targetFile.Close() | |
if err != nil { | |
panic(err) | |
} | |
buf := make([]byte, 1024) | |
for { | |
n, err := sourceFileFile.Read(buf) | |
if err != nil && err != io.EOF { | |
panic(err) | |
} | |
if n == 0 { | |
break | |
} | |
if _, err := targetFile.Write(buf[:n]); err != nil { | |
panic(err) | |
} | |
} | |
fmt.Println() | |
} | |
return | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use:
.OIV
file using 7-zip into a new folder.convert.go
in that folder.go run convert.go
.A new folder named
onigiri
will be created. Move this folder to your GTA5 installation folder.onigiri.asi
is required to load replacement files from theonigiri
folder.I don't know where else you can obtain this other than downloading NaturalVision Enhanced.
Don't want to compile it yourself?
Download the binary executable here: https://gofile.io/d/D2Uley
Use at your own risk. This program is provided as-is, with no warranties whatsoever. You are fully responsible for anything that may happen by running this program.