2025-06-12 09:41:46 +02:00
|
|
|
package fmp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2025-06-12 10:53:31 +02:00
|
|
|
"strings"
|
2025-06-12 09:41:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (f *FmpFile) ToDebugFile(fname string) {
|
2025-06-12 10:53:31 +02:00
|
|
|
f_chunks, err := os.Create(fname + ".chunks")
|
2025-06-12 09:41:46 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer func() {
|
2025-06-12 10:53:31 +02:00
|
|
|
if err := f_chunks.Close(); err != nil {
|
2025-06-12 09:41:46 +02:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
for _, chunk := range f.Chunks {
|
2025-06-12 10:53:31 +02:00
|
|
|
fmt.Fprintf(f_chunks, "%s, %s\n", chunk.String(), string(chunk.Value))
|
|
|
|
}
|
|
|
|
|
|
|
|
f_dicts, err := os.Create(fname + ".dicts")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
2025-06-12 09:41:46 +02:00
|
|
|
}
|
2025-06-12 10:53:31 +02:00
|
|
|
defer func() {
|
|
|
|
if err := f_dicts.Close(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
fmt.Fprint(f_dicts, f.Dictionary.String())
|
2025-06-12 09:41:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *FmpChunk) String() string {
|
|
|
|
return fmt.Sprintf("<%v(%v)>", c.Type, c.Length)
|
|
|
|
}
|
2025-06-12 10:53:31 +02:00
|
|
|
|
|
|
|
func (dict *FmpDict) String() string {
|
|
|
|
s := ""
|
|
|
|
for k, v := range *dict {
|
|
|
|
ns := strings.ReplaceAll(v.Children.String(), "\n", "\n\t")
|
|
|
|
s += fmt.Sprintf("%v: %v\n%v\n", k, string(v.Value), ns)
|
|
|
|
}
|
|
|
|
return s
|
|
|
|
}
|