private static PlayList LoadM3U(string archiveFile, string fileName, string zipFileName) { try { PlayList pl = new PlayList(); UnlhaWrap.UnlhaCmd cmd = new UnlhaWrap.UnlhaCmd(); byte[] buf = cmd.GetFileByte(archiveFile, fileName); string[] text = Encoding.GetEncoding(932).GetString(buf).Split(new string[] { "\r\n" }, StringSplitOptions.None); foreach (string txt in text) { string line = txt.Trim(); if (line == "") { continue; } if (line[0] == '#') { continue; } PlayList.music ms = analyzeLine(line, ""); ms.format = common.CheckExt(ms.fileName); ms.arcFileName = zipFileName; if (ms != null) { pl.lstMusic.Add(ms); } } return(pl); } catch (Exception ex) { log.ForcedWrite(ex); return(new PlayList()); } }
private void AddFileSID(music mc, object entry = null) { try { byte[] buf = null; if (entry == null) { buf = File.ReadAllBytes(mc.fileName); } else { if (entry is ZipArchiveEntry) { using (BinaryReader reader = new BinaryReader(((ZipArchiveEntry)entry).Open())) { buf = reader.ReadBytes((int)((ZipArchiveEntry)entry).Length); } } else { UnlhaWrap.UnlhaCmd cmd = new UnlhaWrap.UnlhaCmd(); buf = cmd.GetFileByte(((Tuple <string, string>)entry).Item1, ((Tuple <string, string>)entry).Item2); } } List <PlayList.music> musics; if (entry == null) { musics = Audio.getMusic(mc.fileName, buf); } else { musics = Audio.getMusic(mc.fileName, buf, mc.arcFileName, entry); } if (mc.songNo != -1) { PlayList.music music = null; if (musics.Count > 0) { music = musics[0]; music.songNo = mc.songNo; music.title = mc.title; music.titleJ = mc.titleJ; musics.Clear(); musics.Add(music); } else { musics.Clear(); } } List <DataGridViewRow> rows = makeRow(musics); foreach (DataGridViewRow row in rows) { dgvList.Rows.Add(row); } foreach (PlayList.music music in musics) { lstMusic.Add(music); } } catch (Exception ex) { log.ForcedWrite(ex); } }
private void AddFileLZH(music mc, object entry = null) { if (entry != null) { return; } UnlhaWrap.UnlhaCmd cmd = new UnlhaWrap.UnlhaCmd(); List <Tuple <string, UInt64> > res = cmd.GetFileList(mc.fileName, "*.*"); mc.arcFileName = mc.fileName; mc.arcType = EnmArcType.LZH; List <string> zipMember = new List <string>(); List <music> mMember = new List <music>(); foreach (Tuple <string, UInt64> ent in res) { if (Common.CheckExt(ent.Item1) != EnmFileFormat.M3U) { zipMember.Add(ent.Item1); } else { PlayList pl = M3U.LoadM3U(ent, mc.arcFileName); foreach (music m in pl.lstMusic) { mMember.Add(m); } } } foreach (string zm in zipMember) { bool found = false; foreach (music m in mMember) { if (m.fileName == zm) { found = true; break; } } if (!found && Common.CheckExt(zm) == EnmFileFormat.VGM) { string vzm = ""; if (Path.GetExtension(zm).ToLower() == ".vgm") { vzm = Path.ChangeExtension(zm, ".vgz"); } else { vzm = Path.ChangeExtension(zm, ".vgm"); } foreach (music m in mMember) { if (m.fileName == vzm) { found = true; break; } } } if (!found) { music zmc = new music(); zmc.fileName = zm; zmc.arcFileName = mc.arcFileName; zmc.arcType = mc.arcType; mMember.Add(zmc); } } foreach (Tuple <string, UInt64> ent in res) { foreach (music m in mMember) { string vzm = ""; if (Path.GetExtension(m.fileName).ToLower() == ".vgm") { vzm = Path.ChangeExtension(m.fileName, ".vgz"); } else if (Path.GetExtension(m.fileName).ToLower() == ".vgz") { vzm = Path.ChangeExtension(m.fileName, ".vgm"); } if (ent.Item1 == m.fileName || ent.Item1 == vzm) { m.format = Common.CheckExt(m.fileName); m.arcFileName = mc.arcFileName; m.arcType = mc.arcType; AddFileLoop(m, new Tuple <string, string>(m.arcFileName, ent.Item1)); } } } }
/// <summary> /// 汎用 /// </summary> private void AddFilexxx(music mc, object entry = null) { try { byte[] buf = null; if (entry == null) { try { buf = File.ReadAllBytes(mc.fileName); } catch (Exception ex) { log.ForcedWrite(ex); buf = null; } if (buf == null && mc.format == EnmFileFormat.VGM) { if (Path.GetExtension(mc.fileName).ToLower() == ".vgm") { mc.fileName = Path.ChangeExtension(mc.fileName, ".vgz"); } else { mc.fileName = Path.ChangeExtension(mc.fileName, ".vgm"); } try { buf = File.ReadAllBytes(mc.fileName); } catch (Exception ex) { log.ForcedWrite(ex); buf = null; } } } else { if (entry is ZipArchiveEntry) { using (BinaryReader reader = new BinaryReader(((ZipArchiveEntry)entry).Open())) { try { buf = reader.ReadBytes((int)((ZipArchiveEntry)entry).Length); } catch (Exception ex) { log.ForcedWrite(ex); buf = null; } } } else { UnlhaWrap.UnlhaCmd cmd = new UnlhaWrap.UnlhaCmd(); buf = cmd.GetFileByte(((Tuple <string, string>)entry).Item1, ((Tuple <string, string>)entry).Item2); } } List <PlayList.music> musics; if (entry == null) { musics = Audio.getMusic(mc.fileName, buf); } else { musics = Audio.getMusic(mc.fileName, buf, mc.arcFileName, entry); } List <DataGridViewRow> rows = makeRow(musics); foreach (DataGridViewRow row in rows) { dgvList.Rows.Add(row); } foreach (PlayList.music music in musics) { lstMusic.Add(music); } } catch (Exception ex) { log.ForcedWrite(ex); } }