Exemple #1
0
 public static LingeaSndFiles addSoundsStart(Langs lng, bool force = false) {
   string fn = basicPath + "\\" + lng.ToString() + ".xml";
   if (!force && File.Exists(fn)) {
     var res = XmlUtils.FileToObject<LingeaSndFiles>(fn);
     //File.Delete(fn);
     return res;
   } else {
     var res = new LingeaSndFiles() { lng = lng };
     res.files = Directory.EnumerateFiles(res.BasicPath, "*.xml").Select(f => XmlUtils.FileToObject<LingeaSndFile>(f)).ToList();
     XmlUtils.ObjectToFile(fn, res);
     return res;
   }
 }
Exemple #2
0
 public string Path(LingeaSndFiles owner, bool isMP3) { return owner.BasicPath + "\\" + fileName + (isMP3 ? ".mp3" : ".xml"); }
Exemple #3
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);
 }
Exemple #4
0
 public bool theSame(LingeaSndFiles owner, byte[] data) {
   byte[] self = File.ReadAllBytes(Path(owner, true));
   return self.SequenceEqual(data);
 }