func DumpMMSFolder(f *nbu.Reader, off int64, destdir string) { title, msgs, err := f.ReadMMSFolderAt(off) if err != nil { log.Printf("could not parse MMS folder at offset 0x%x: %s", off, err) return } dir := filepath.Join(destdir, "mms", title) err = os.MkdirAll(dir, 0755) if err != nil { log.Fatalf("could not create directory %s: %s", dir, err) } log.Printf("writing %d MMS to %s", len(msgs), dir) for i, msg := range msgs { base := fmt.Sprintf("%06d.mms", i+1) err := ioutil.WriteFile(filepath.Join(dir, base), msg, 0644) if err != nil { log.Printf("could not write %s: %s", base, err) } // try parsing. buf := bytes.NewBuffer(msg) m, err := mms.ReadMMS(buf) log.Printf("err=%s", err) log.Printf("%+v", m) } }
func DumpSMSFolder(f *nbu.Reader, off int64, destdir string) { title, msgs, err := f.ReadMessageFolderAt(off) if err != nil { log.Printf("could not parse message folder at offset 0x%x: %s", off, err) return } dir := filepath.Join(destdir, "sms", title) err = os.MkdirAll(dir, 0755) if err != nil { log.Fatalf("could not create directory %s: %s", dir, err) } log.Printf("writing %d SMS to %s", len(msgs), dir) for i, msg := range msgs { base := fmt.Sprintf("%06d.vmsg", i+1) err := ioutil.WriteFile(filepath.Join(dir, base), []byte(msg), 0644) if err != nil { log.Printf("could not write %s: %s", base, err) } } }