Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Oct 11, 2023
1 parent 84a2968 commit aaed78e
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions parser/filehandling.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
// GetRenpyContent opens all renpy files and transform them into a string list
// 1 line of script = 1 list element
func GetRenpyContent(rootPath string) []string {

files, err := walkMatch(rootPath, "*.rpy")
if err != nil {
log.Fatalf("failed to find root folder: %s", err)
Expand All @@ -20,34 +19,37 @@ func GetRenpyContent(rootPath string) []string {
var fileTextLines []string

for _, file := range files {
if ConsiderAsUseful(file) {
readFile, err := os.Open(file)
if err != nil {
log.Fatalf("failed to open file: %s", err)
}
if !ConsiderAsUseful(file) {
continue
}

var bom [3]byte
_, err = io.ReadFull(readFile, bom[:])
readFile, err := os.Open(file)
if err != nil {
log.Fatalf("failed to open file: %s", err)
}

var bom [3]byte
_, err = io.ReadFull(readFile, bom[:])
if err != nil {
log.Fatal(err)
}
if bom[0] != 0xef || bom[1] != 0xbb || bom[2] != 0xbf {
_, err = readFile.Seek(0, 0) // Not a BOM -- seek back to the beginning
if err != nil {
log.Fatal(err)
}
if bom[0] != 0xef || bom[1] != 0xbb || bom[2] != 0xbf {
_, err = readFile.Seek(0, 0) // Not a BOM -- seek back to the beginning
if err != nil {
log.Fatal("error in file", file, err)
}
log.Fatal("error in file", file, err)
}
}

fileScanner := bufio.NewScanner(readFile)
fileScanner.Split(bufio.ScanLines)
fileScanner := bufio.NewScanner(readFile)
fileScanner.Split(bufio.ScanLines)

for fileScanner.Scan() {
fileTextLines = append(fileTextLines, fileScanner.Text())
}
fileTextLines = append(fileTextLines, "# renpy-graphviz: BREAK")

readFile.Close()
for fileScanner.Scan() {
fileTextLines = append(fileTextLines, fileScanner.Text())
}
fileTextLines = append(fileTextLines, "# renpy-graphviz: BREAK")

readFile.Close()

}

return fileTextLines
Expand Down

0 comments on commit aaed78e

Please sign in to comment.