Beispiel #1
0
 public static void addSound(LingeaSndFile[] files, LingeaSndFiles[] owners, LingeaSndFile newFile, LingeaSndFiles newOwner) {
   var data = File.ReadAllBytes(newFile.Path(newOwner, true));
   var sameFile = files.Zip(owners, (file, owner) => new { file, owner }).FirstOrDefault(f => f.file.theSame(f.owner, data));
   if (sameFile == null) return;
   //merge newFile do sameFile a vymaz newFile
   foreach (var cl in newFile.clones) if (!sameFile.file.clones.Any(c => c.fileName == cl.fileName))
       sameFile.file.clones.Add(cl);
   File.Copy(newFile.Path(newOwner, true), @"d:\temp\duplSounds\" + newFile.fileName + ".mp3", true);
   File.Delete(newFile.Path(newOwner, true));
   File.Copy(newFile.Path(newOwner, false), @"d:\temp\duplSounds\" + newFile.fileName + ".xml", true);
   File.Delete(newFile.Path(newOwner, false));
   XmlUtils.ObjectToFile(sameFile.file.Path(sameFile.owner, false), sameFile.file);
 }
Beispiel #2
0
 public void addSound(string fileName, byte[] data, string word) {
   fileName = fileName.ToLower();
   long crc = ZipStream.Crc(data);
   var sameFile = files.Where(f => f.crc == crc).FirstOrDefault(f => f.theSame(this, data));
   if (sameFile == null) {
     files.Add(sameFile = new LingeaSndFile() {
       fileName = fileName,
       crc = crc,
       clones = new List<LingeaSndClone>() {  new LingeaSndClone() { fileName = fileName, word = word, }
     }
     });
     File.WriteAllBytes(sameFile.Path(this, true), data);
   } else {
     if (sameFile.clones.Any(f => f.fileName == fileName)) return;
     sameFile.clones.Add(new LingeaSndClone() { fileName = fileName, word = word, });
   }
   XmlUtils.ObjectToFile(sameFile.Path(this, false), sameFile);
 }