// Initialize private members to pre-opened state void init (void) { if (m_stream) { m_stream->Close (); delete m_stream; m_stream = NULL; } m_buf.clear (); }
// Initialize private members to pre-opened state void init (void) { if (m_stream) { m_stream->Close (); delete m_stream; m_stream = NULL; } m_buf.clear (); m_subimage = 0; m_subimages_to_write = 0; m_subimage_specs.clear (); m_write_pending = false; }
Bool BonkEnc::CueSheet::Save(const String &fileName) { if (fileNames.Length() == 0) return False; OutStream *file = new OutStream(STREAM_FILE, fileName, OS_OVERWRITE); /* Write UTF-8 BOM and set output format. */ file->OutputNumber(0xEF, 1); file->OutputNumber(0xBB, 1); file->OutputNumber(0xBF, 1); String format = String::SetOutputFormat("UTF-8"); /* Check if all tracks belong to the same album and * if we need to create a single or multi file cue sheet. */ Bool album = True; Bool oneFile= True; for (Int c = 0; c < fileNames.Length() - 1; c++) { if (trackArtists.GetNth(c) != trackArtists.GetNth(c + 1) || trackAlbums.GetNth(c) != trackAlbums.GetNth(c + 1)) { album = False; } if (fileNames.GetNth(c) != fileNames.GetNth(c + 1)) { oneFile = False; } } /* Metadata. */ if (album) { file->OutputLine(String("PERFORMER \"").Append(trackArtists.GetFirst()).Append("\"")); file->OutputLine(String("TITLE \"").Append(trackAlbums.GetFirst()).Append("\"")); } /* Write actual track data. */ if (oneFile) { file->OutputLine(String("FILE \"").Append(fileNames.GetNth(0)).Append("\" WAVE")); } for (Int i = 0; i < fileNames.Length(); i++) { Int minutes = trackOffsets.GetNth(i) / (75 * 60); Int seconds = (trackOffsets.GetNth(i) - (minutes * 60 * 75)) / 75 ; Int frames = trackOffsets.GetNth(i) - (seconds * 75) - (minutes * 60 * 75) ; if (!oneFile) file->OutputLine(String("FILE \"").Append(fileNames.GetNth(i)).Append("\" WAVE")); file->OutputLine(String(" TRACK ").Append(i < 9 ? "0" : "").Append(String::FromInt(i + 1)).Append(" AUDIO")); file->OutputLine(String(" TITLE \"").Append(trackTitles.GetNth(i)).Append("\"")); file->OutputLine(String(" PERFORMER \"").Append(trackArtists.GetNth(i)).Append("\"")); file->OutputLine(String(" INDEX 01 ").Append(minutes < 10 ? "0" : "").Append(String::FromInt(minutes)).Append(":") .Append(seconds < 10 ? "0" : "").Append(String::FromInt(seconds)).Append(":") .Append(frames < 10 ? "0" : "").Append(String::FromInt(frames ))); } file->Close(); delete file; /* Restore previous output format. */ String::SetOutputFormat(format); return True; }