Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            FFmpeg.Initialize(@"C:\Program Files (x86)\ffmpeg\ffmpeg.exe","metaflac.exe");

            /*FileData d = FileService.ReadFile("test.txt");
            if (d.Type == FileDataType.IndexFile)
            {
                IndexFile ii = d.o._Cast<IndexFile>();
                ii.Update();
            }*/


            
            FileSystemPlusLoadOption lo = new FileSystemPlusLoadOption();
            lo.IgnoreException = true;
            lo.RestrictExtensionEnable = true;
            lo.RestrictExtension.AddToLower("flac");
            lo.RestrictExtension.AddToLower("mp3");

            FFmpeg.Initialize(@"C:\Program Files (x86)\ffmpeg\ffmpeg.exe", "metaflac.exe");
            //IndexFile I = 
          
            IndexFile i = new IndexFile();
            i.OnEnd += I_OnEnd;
            i.BeginLoadFromPath(@"F:\MUSICA FLAC\ORATORIO\", lo);
    


        }
Example #2
0
 private void I_OnEnd(IndexFile i)
 {
     FileService.WriteFile("test.txt", i, FileDataType.IndexFile);
     /*FileData d=FileService.ReadFile("test.txt");
     if(d.Type==FileDataType.IndexFile)
     {
         IndexFile ii = d.o._Cast<IndexFile>();
     }*/
 }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            FFmpeg.Initialize(@"C:\Program Files (x86)\ffmpeg\ffmpeg.exe", "metaflac.exe");

            FileSystemPlusLoadOption lo = new FileSystemPlusLoadOption();
            lo.IgnoreException = true;
            lo.RestrictExtensionEnable = true;
            lo.RestrictExtension.AddToLower("flac");
            lo.RestrictExtension.AddToLower("mp3");


            IndexFile i = new IndexFile();
            i.OnEnd += I_OnEnd2;
            i.BeginLoadFromPath(@"D:\Musica\DJ CAVA Mashups\", lo);


            
            /* Wrapper w = new Wrapper(new FFMpegMediaMetadataFlac());
             String ser = Json.Serialize(w);
             Wrapper tret = Json.Deserialize<Wrapper>(ser);*/

            //D:\Musica\DJ CAVA Mashups

        }
Example #4
0
        /// <summary>
        /// Performs the base level alteration to the CMP file, without going through .rgsp files.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="index"></param>
        /// <param name="modlist"></param>
        /// <returns></returns>
        private static async Task SetScalingParameter(RacialGenderScalingParameter data, IndexFile index = null, ModList modlist = null)
        {
            var cmp = await GetCharaMakeParameterSet(false, index, modlist);

            cmp.SetScalingParameter(data);
            await SaveCharaMakeParameterSet(cmp, index, modlist);
        }
Example #5
0
        public static async Task <RacialGenderScalingParameter> GetScalingParameter(XivSubRace race, XivGender gender, bool forceOriginal = false, IndexFile index = null, ModList modlist = null)
        {
            var cmp = await GetCharaMakeParameterSet(forceOriginal, index, modlist);

            return(cmp.GetScalingParameter(race, gender));
        }
Example #6
0
        /// <summary>
        /// Saves a racial scaling entry to file.
        /// </summary>
        /// <param name="rgsp"></param>
        /// <param name=""></param>
        /// <returns></returns>
        public static async Task SaveScalingParameter(RacialGenderScalingParameter rgsp, string sourceApplication, IndexFile index = null, ModList modlist = null)
        {
            // Write the .rgsp file and let the DAT functions handle applying it.
            var rgspFilePath = GetRgspPath(rgsp.Race, rgsp.Gender);

            var bytes = rgsp.GetBytes();


            var dummyItem = new XivGenericItemModel();

            dummyItem.Name = rgsp.Race.GetDisplayName() + " - " + rgsp.Gender.ToString();
            dummyItem.SecondaryCategory = "Racial Scaling";

            var _dat = new Dat(XivCache.GameInfo.GameDirectory);
            await _dat.ImportType2Data(bytes, rgspFilePath, sourceApplication, dummyItem, index, modlist);
        }
Example #7
0
 private void IdxFileChanged(IndexFile file, string oldHash)
 {
     Console.WriteLine(@"File changed: " + file.hash);
     //Currently not implemented
 }
Example #8
0
        /// <summary>
        /// Applies a custom .rgsp file to the main Human.CMP file.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="index"></param>
        /// <param name="modlist"></param>
        /// <returns></returns>
        internal static async Task ApplyRgspFile(byte[] data, IndexFile index = null, ModList modlist = null)
        {
            var rgsp = new RacialGenderScalingParameter(data);

            await SetScalingParameter(rgsp, index, modlist);
        }
Example #9
0
        public ActionResult AddIndex(Table table)
        {
            var realField = new Field();
            var realTable = new Table();

            foreach (var db in _databases)
            {
                foreach (var t in db.Tables)
                {
                    if (t.Name == table.Name)
                    {
                        foreach (var f in t.Fields)
                        {
                            if (f.Name == table.Index)
                            {
                                realField = f;
                                realTable = t;
                            }
                        }
                    }
                }
            }

            var indexFile = new IndexFile
            {
                Indexs = new List <Index>()
                {
                    new Index {
                        IndexName = table.FileName
                    }
                },                                                                   // index name is set on FileName attribute in _AddIndex.cshtml
                KeyLength = realField.Length,
                FileName  = $"{table.FileName}.ind",
                IndexType = table.IndexType,
                IsUnique  = table.IndexUnique
            };

            if (!_currentTable.IndexFiles.Any(c => c.Indexs.Any(z => z.IndexName == table.Index)))
            {
                if (table.IndexUnique)
                {
                    _currentTable.IndexFiles.Add(indexFile);

                    var value = string.Empty;

                    var fieldsNotPk = realTable.Fields.Where(c => realTable.PrimaryKey != c.Name);

                    foreach (var s in fieldsNotPk)
                    {
                        if (s.Name != indexFile.Indexs.FirstOrDefault()?.IndexName)
                        {
                            value += s.Name + "#";
                        }
                    }
                    value = value.Remove(value.Length - 1);

                    using (var tranz = _dBreeze.GetTransaction())
                    {
                        if (!_dBreeze.Scheme.IfUserTableExists(table.FileName))
                        {
                            tranz.InsertTable(table.FileName, table.Index, 0);

                            var pairs = DBreezeOperations.GetAllData(_dBreeze, table.Name).OrderBy(c => c.Key);

                            foreach (var v in pairs)
                            {
                                tranz.Insert(table.Index, v.Key, v.Value);
                            }
                        }

                        tranz.Commit();
                    }
                }
            }
            else
            {
                // non-unique index file
            }


            return(View("Fields", _currentTable));
        }
        /// <summary>
        /// Restores the original SE metadata for this root.
        /// This should only be called by Index.DeleteFileDescriptor().
        /// </summary>
        public static async Task RestoreDefaultMetadata(XivDependencyRoot root, IndexFile index = null, ModList modlist = null)
        {
            var original = await ItemMetadata.CreateFromRaw(root, true);

            await ApplyMetadata(original, index, modlist);
        }
        /// <summary>
        /// Applies this Metadata object to the FFXIV file system.
        /// This should only called by Dat.WriteToDat() / RestoreDefaultMetadata()
        /// </summary>
        internal static async Task ApplyMetadata(ItemMetadata meta, IndexFile index = null, ModList modlist = null)
        {
            var _eqp     = new Eqp(XivCache.GameInfo.GameDirectory);
            var _modding = new Modding(XivCache.GameInfo.GameDirectory);
            var _index   = new Index(XivCache.GameInfo.GameDirectory);
            var df       = IOUtil.GetDataFileFromPath(meta.Root.Info.GetRootFile());

            var dummyItem = new XivGenericItemModel();

            dummyItem.Name = Constants.InternalModSourceName;
            dummyItem.SecondaryCategory = Constants.InternalModSourceName;


            // Beep boop
            bool doSave = false;

            if (index == null)
            {
                doSave = true;
                index  = await _index.GetIndexFile(df);

                modlist = await _modding.GetModListAsync();
            }


            if (meta.ImcEntries.Count > 0)
            {
                var _imc    = new Imc(XivCache.GameInfo.GameDirectory);
                var imcPath = meta.Root.GetRawImcFilePath();
                await _imc.SaveEntries(imcPath, meta.Root.Info.Slot, meta.ImcEntries, dummyItem, index, modlist);
            }

            // Applying EQP data via set 0 is not allowed, as it is a special set hard-coded to use Set 1's data.
            if (meta.EqpEntry != null && !(meta.Root.Info.PrimaryType == Items.Enums.XivItemType.equipment && meta.Root.Info.PrimaryId == 0))
            {
                await _eqp.SaveEqpEntry(meta.Root.Info.PrimaryId, meta.EqpEntry, dummyItem, index, modlist);
            }

            if (meta.EqdpEntries.Count > 0)
            {
                await _eqp.SaveEqdpEntries((uint)meta.Root.Info.PrimaryId, meta.Root.Info.Slot, meta.EqdpEntries, dummyItem, index, modlist);
            }

            if (meta.EstEntries.Count > 0)
            {
                var type    = Est.GetEstType(meta.Root);
                var entries = meta.EstEntries.Values.ToList();
                await Est.SaveExtraSkeletonEntries(type, entries, dummyItem, index, modlist);
            }

            if (meta.GmpEntry != null)
            {
                await _eqp.SaveGimmickParameter(meta.Root.Info.PrimaryId, meta.GmpEntry, dummyItem, index, modlist);
            }

            if (doSave && !XivCache.GameInfo.UseLumina)
            {
                await _index.SaveIndexFile(index);

                await _modding.SaveModListAsync(modlist);
            }
        }
        /// <summary>
        /// Applies multiple metadata mods simultaneously for performance gains.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="index"></param>
        /// <param name="modlist"></param>
        /// <returns></returns>
        internal static async Task ApplyMetadataBatched(List <ItemMetadata> data, IndexFile index, ModList modlist, bool save = true)
        {
            if (data == null || data.Count == 0)
            {
                return;
            }

            var _eqp     = new Eqp(XivCache.GameInfo.GameDirectory);
            var _modding = new Modding(XivCache.GameInfo.GameDirectory);
            var _index   = new Index(XivCache.GameInfo.GameDirectory);

            var dummyItem = new XivGenericItemModel();

            dummyItem.Name = Constants.InternalModSourceName;
            dummyItem.SecondaryCategory = Constants.InternalModSourceName;

            Dictionary <XivRace, List <(uint PrimaryId, string Slot, EquipmentDeformationParameter Entry)> > eqdpEntries = new Dictionary <XivRace, List <(uint PrimaryId, string Slot, EquipmentDeformationParameter Entry)> >();
            Dictionary <Est.EstType, List <ExtraSkeletonEntry> > estEntries = new Dictionary <Est.EstType, List <ExtraSkeletonEntry> >();
            List <(uint PrimaryId, EquipmentParameter EqpData)>  eqpEntries = new List <(uint PrimaryId, EquipmentParameter EqpData)>();
            List <(uint PrimaryId, GimmickParameter GmpData)>    gmpEntries = new List <(uint PrimaryId, GimmickParameter GmpData)>();

            foreach (var meta in data)
            {
                // Construct the parameter collections for each function call.
                foreach (var kv in meta.EqdpEntries)
                {
                    if (!eqdpEntries.ContainsKey(kv.Key))
                    {
                        eqdpEntries.Add(kv.Key, new List <(uint PrimaryId, string Slot, EquipmentDeformationParameter Entry)>());
                    }

                    eqdpEntries[kv.Key].Add(((uint)meta.Root.Info.PrimaryId, meta.Root.Info.Slot, kv.Value));
                }

                var estType = Est.GetEstType(meta.Root);
                foreach (var kv in meta.EstEntries)
                {
                    if (!estEntries.ContainsKey(estType))
                    {
                        estEntries.Add(estType, new List <ExtraSkeletonEntry>());
                    }

                    estEntries[estType].Add(kv.Value);
                }

                if (meta.EqpEntry != null)
                {
                    eqpEntries.Add(((uint)meta.Root.Info.PrimaryId, meta.EqpEntry));
                }

                if (meta.GmpEntry != null)
                {
                    gmpEntries.Add(((uint)meta.Root.Info.PrimaryId, meta.GmpEntry));
                }
            }


            if (index.DataFile == XivDataFile._04_Chara)
            {
                // Batch install functions for these three.
                await _eqp.SaveEqpEntries(eqpEntries, dummyItem, index, modlist);

                await _eqp.SaveEqdpEntries(eqdpEntries, dummyItem, index, modlist);

                await _eqp.SaveGmpEntries(gmpEntries, dummyItem, index, modlist);

                // The EST function already does batch applications by nature of how it works,
                // so just call it once for each of the four EST types represented.
                foreach (var kv in estEntries)
                {
                    await Est.SaveExtraSkeletonEntries(kv.Key, kv.Value, dummyItem, index, modlist);
                }
            }


            // IMC Files don't really overlap that often, so it's
            // not a significant loss generally to just write them individually.
            foreach (var meta in data)
            {
                if (meta.ImcEntries.Count > 0)
                {
                    var _imc    = new Imc(XivCache.GameInfo.GameDirectory);
                    var imcPath = meta.Root.GetRawImcFilePath();
                    await _imc.SaveEntries(imcPath, meta.Root.Info.Slot, meta.ImcEntries, null, index, modlist);
                }
            }

            if (save)
            {
                await _index.SaveIndexFile(index);

                await _modding.SaveModListAsync(modlist);
            }
        }
        /// <summary>
        /// Retrieves the item metadata from a cached index setup (or raw)
        /// </summary>
        /// <param name="root"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static async Task <ItemMetadata> GetFromCachedIndex(XivDependencyRoot root, IndexFile index)
        {
            var _dat = new Dat(XivCache.GameInfo.GameDirectory);
            var df   = IOUtil.GetDataFileFromPath(root.Info.GetRootFile());

            long offset = 0;

            if (index != null)
            {
                offset = index.Get8xDataOffset(root.Info.GetRootFile());
            }

            ItemMetadata mData = null;

            if (offset == 0)
            {
                mData = await ItemMetadata.GetMetadata(root);
            }
            else
            {
                var data = await _dat.GetType2Data(offset, df);

                mData = await ItemMetadata.Deserialize(data);
            }
            return(mData);
        }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="script"></param>
        /// <param name="fileManager"></param>
        /// <returns></returns>
        public static bool ApplyScript(Script script, ref FileManager fileManager)
        {
            #region Table Modifications
            if (script.Tables != null)
            {
                foreach (Script.Table table in script.Tables)
                {
                    string tableID = table.ID.ToUpper();
                    if (fileManager.DataFiles.ContainsKey(tableID) == false)
                    {
                        Console.WriteLine(String.Format("Error: The table id is incorrect or does not exist: {0} ", tableID));
                        continue;
                    }

                    ExcelFile dataTable = fileManager.DataFiles[tableID] as ExcelFile;
                    if (dataTable == null)
                    {
                        Console.WriteLine(String.Format("Error: Could not open {0} due to null reference.", tableID));
                        continue;
                    }

                    foreach (Script.Table.Entity entity in table.Entities)
                    {
                        foreach (Script.Table.Entity.Attribute attribute in entity.Attributes)
                        {
                            string   whereColumn = String.Empty;
                            string[] whereValue  = null;
                            int      step        = 0;
                            int      min         = 1;
                            int      max         = 0;
                            int      last        = 0; //for recursive function
                            string   function;
                            int[]    list;

                            try
                            {
                                //determine the range
                                if (entity.ID.Contains(","))
                                {
                                    string[] explode = entity.ID.Split(',');
                                    list = new int[explode.Length];

                                    for (int i = 0; i < list.Length; i++)
                                    {
                                        list[i] = Convert.ToInt32(explode[i]);
                                    }
                                }
                                else
                                {
                                    if (entity.ID.Contains("*"))
                                    {
                                        min = 0;
                                        max = dataTable.Count - 1;
                                    }
                                    else if (entity.ID.Contains("-"))
                                    {
                                        int idx = entity.ID.IndexOf('-');
                                        int len = entity.ID.Length - idx - 1;
                                        min = Convert.ToInt32(entity.ID.Substring(0, idx));
                                        max = Convert.ToInt32(entity.ID.Substring(idx + 1, len));
                                    }
                                    else
                                    {
                                        min = Convert.ToInt32(entity.ID);
                                        max = Convert.ToInt32(entity.ID);
                                    }

                                    int listlen = max - min + 1;
                                    list = new int[listlen];
                                    int i = 0;

                                    for (int row = min; row <= max; row++)
                                    {
                                        list[i++] = row;
                                    }
                                }

                                //check for where condition
                                if (attribute.Where != null)
                                {
                                    int equalsIndex = attribute.Where.IndexOf('=');
                                    if (equalsIndex == -1)
                                    {
                                        Console.WriteLine("Bad syntax in where condition.");
                                        return(false);
                                    }
                                    whereColumn = attribute.Where.Substring(0, equalsIndex);
                                    string whereValueString = attribute.Where.Substring(equalsIndex + 1, attribute.Where.Length - equalsIndex - 1);
                                    if (whereValueString.Contains('|'))
                                    {
                                        whereValue = whereValueString.Split('|');
                                    }
                                    else
                                    {
                                        whereValue = new string[] { whereValueString };
                                    }
                                }

                                //determine function
                                if (attribute.Bit != null)
                                {
                                    function = "bitwise";
                                }
                                else if (attribute.Operation == null)
                                {
                                    function = "replace";
                                }
                                else if (attribute.Operation.Contains("*"))
                                {
                                    function = "multiply";
                                }
                                else if (attribute.Operation.Contains("/"))
                                {
                                    function = "divide";
                                }
                                else if (attribute.Operation.Contains("+"))
                                {
                                    string s = attribute.Operation.Remove(0);
                                    step     = Convert.ToInt32(s);
                                    function = "recursive";
                                }
                                else if (attribute.Operation.Contains("-"))
                                {
                                    step     = Convert.ToInt32(attribute.Operation);
                                    function = "recursive";
                                }
                                else
                                {
                                    continue; // syntax error
                                }

                                //main loop, alters the dataset
                                foreach (int row in list)
                                {
                                    object obj          = null;
                                    string col          = attribute.ID;
                                    Type   type         = dataTable.DataType.GetField(col).FieldType;
                                    Object currentValue = dataTable.DataType.GetField(col).GetValue(dataTable.Rows[row]);

                                    if (String.IsNullOrEmpty(whereColumn) == false)
                                    {
                                        Type   typeWhere         = dataTable.DataType.GetField(whereColumn).FieldType;
                                        Object currentValueWhere = dataTable.DataType.GetField(whereColumn).GetValue(dataTable.Rows[row]);
                                        if (whereValue.Where(val => FileTools.StringToObject(val, typeWhere).Equals(currentValueWhere)).Any() == false)
                                        {
                                            continue;
                                        }
                                    }

                                    switch (function)
                                    {
                                    case "replace":
                                        obj = FileTools.StringToObject(attribute.Data, type);
                                        break;

                                    case "multiply":
                                        if (type.Equals(typeof(int)))
                                        {
                                            obj = (int)currentValue * Convert.ToInt32(attribute.Data);
                                        }
                                        else if (type.Equals(typeof(float)))
                                        {
                                            obj = (float)currentValue * Convert.ToSingle(attribute.Data);
                                        }
                                        break;

                                    case "divide":
                                        if (type.Equals(typeof(int)))
                                        {
                                            obj = (int)currentValue / Convert.ToInt32(attribute.Data);
                                        }
                                        else if (type.Equals(typeof(float)))
                                        {
                                            obj = (float)currentValue / Convert.ToSingle(attribute.Data);
                                        }
                                        break;

                                    case "bitwise":
                                        uint bit     = (uint)Enum.Parse(type, attribute.Bit, true);
                                        uint mask    = (uint)currentValue;
                                        bool flick   = Convert.ToBoolean(attribute.Data);
                                        bool current = (mask & bit) > 0;
                                        if (flick != current)
                                        {
                                            obj = mask ^= bit;
                                        }
                                        else
                                        {
                                            obj = mask;
                                        }
                                        break;

                                    case "recursive":
                                        if (row.Equals(min))    //first time only
                                        {
                                            if (type.Equals(typeof(int)))
                                            {
                                                obj  = Convert.ToInt32(attribute.Data);
                                                last = (int)obj;
                                            }
                                        }
                                        else
                                        {
                                            last += step;
                                            obj   = last;
                                        }
                                        break;
                                    }
                                    dataTable.DataType.GetField(col).SetValue(dataTable.Rows[row], obj);
                                }
                            }
                            catch (Exception ex)
                            {
                                ExceptionLogger.LogException(ex);
                                return(false);
                            }
                        }
                    }
                    fileManager.DataFiles[tableID] = dataTable;
                }
            }
            #endregion

            #region Extraction Script
            if (script.Extraction != null)
            {
                string sourcePath      = Path.Combine(fileManager.HellgateDataPath, script.Extraction.Source + ".idx");
                string destinationPath = sourcePath.Replace(script.Extraction.Source, script.Extraction.Destination);

                // Check source index exists
                if (File.Exists(sourcePath) == false)
                {
                    return(false);
                }

                // Try open the index file
                //byte[] sbuffer;
                PackFile sourceIndex      = new IndexFile(sourcePath);
                PackFile destinationIndex = new IndexFile(destinationPath);
                try
                {
                    sourceIndex.ParseFileBytes(File.ReadAllBytes(sourcePath));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: {0} filed to load. Make sure you have run Hellgate London at least once (MP version for MP files) before installating this modification.", sourceIndex);
                    ExceptionLogger.LogException(ex);
                    return(false);
                }

                sourceIndex.BeginDatReading();

                // Extract each path/file
                foreach (PackFileEntry fileEntry in sourceIndex.Files)
                {
                    if (!script.Extraction.paths.Where(p => Regex.IsMatch(fileEntry.Path, p.Replace(@"\", @"\\"))).Any())
                    {
                        continue;
                    }

                    byte[] fileBytes = sourceIndex.GetFileBytes(fileEntry);
                    //if (fileEntry.FileNameString.Contains(XmlCookedFile.FileExtention))
                    //{
                    //    try
                    //    {
                    //        XmlCookedFile xmlCookedFile = new XmlCookedFile();
                    //        xmlCookedFile.Uncook(fileBytes);

                    //        XmlCookedFile reCooked = new XmlCookedFile();
                    //        fileBytes = reCooked.CookXmlDocument(xmlCookedFile.XmlDoc);
                    //    }
                    //    catch (Exception) { }
                    //}

                    destinationIndex.AddFile(fileEntry.Directory, fileEntry.Name, fileBytes);
                }

                // Write the file
                byte[] ibuffer = destinationIndex.ToByteArray();
                Crypt.Encrypt(ibuffer);
                try
                {
                    File.WriteAllBytes(destinationIndex.Path, ibuffer);
                }
                catch (Exception ex)
                {
                    ExceptionLogger.LogException(ex);
                    return(false);
                }
                finally
                {
                    sourceIndex.EndDatAccess();
                    sourceIndex.Dispose();
                    destinationIndex.Dispose();
                }
            }
            #endregion

            return(true);
        }
Example #15
0
        private static async Task <CharaMakeParameterSet> GetCharaMakeParameterSet(bool forceOriginal = false, IndexFile index = null, ModList modlist = null)
        {
            var _dat = new Dat(XivCache.GameInfo.GameDirectory);

            var data = await _dat.GetType2Data(HumanCmpPath, forceOriginal, index, modlist);

            var cmp = new CharaMakeParameterSet(data);


            return(cmp);
        }
Example #16
0
        private static async Task SaveCharaMakeParameterSet(CharaMakeParameterSet cmp, IndexFile index = null, ModList modlist = null)
        {
            var _dat      = new Dat(XivCache.GameInfo.GameDirectory);
            var dummyItem = new XivGenericItemModel();

            dummyItem.Name = "human.cmp";
            dummyItem.SecondaryCategory = Constants.InternalModSourceName;

            await _dat.ImportType2Data(cmp.GetBytes(), HumanCmpPath, Constants.InternalModSourceName, dummyItem, index, modlist);
        }
Example #17
0
        void LoadIndexFromFile(String PathIndexFile, bool Update = false, String PathMediaLibrary = null, FileSystemPlusLoadOption lo = null, bool GUI = true)
        {
            
            FileData FD = FileService.ReadFile(PathIndexFile);
            if (FD == null)
            {
                if (GUI)
                    MessageBox.Show("File di Index: " + PathIndexFile + " Non trovato.\r\nVerrà creato un nuovo file Indice");
                IndexMediaLibrary = new IndexFile();
                IndexMediaLibrary.LoadOption = lo;
                FileService.WriteFile(PathIndexFile, IndexMediaLibrary, FileDataType.IndexFile);
            }
            else if (FD.o == null || !(FD.o is IndexFile))
            {
                if (GUI)
                    MessageBox.Show("File di Index: " + PathIndexFile + " non caricato correttamente.\r\nVerrà creato un nuovo file Indice");
                IndexMediaLibrary = new IndexFile();
                IndexMediaLibrary.LoadOption = lo;
                FileService.WriteFile(PathIndexFile, IndexMediaLibrary, FileDataType.IndexFile);
            }
            else
            {
                IndexMediaLibrary = FD.o._Cast<IndexFile>();
                if(lo!=null)
                    IndexMediaLibrary.LoadOption = lo;
            }


            if (Update)
            {
                Index_UpdateAndSave(PathIndexFile, PathMediaLibrary, null); 
            }


        }
Example #18
0
 /// <summary>
 /// Handles a missing file by trying to download it from
 /// the network.
 /// </summary>
 /// <param name="idxfile">The file to be downloaded.</param>
 private static void Idx_FileMissing(IndexFile idxfile)
 {
     Console.WriteLine(@"File missing initiating download of " + idxfile.hash);
     _p2P.DownloadFile(idxfile.hash);
 }
Example #19
0
        void Index_UpdateAndSave(String PathIndexFile,String PathMediaLibrary = null, FileSystemPlusLoadOption lo = null)
        {
            if (IndexMediaLibrary == null)
            {
                IndexMediaLibrary = new IndexFile();
            }

            if (lo != null)
            {
                IndexMediaLibrary.LoadOption = lo;
            }
                

            if (PathMediaLibrary != null)
                IndexMediaLibrary.Update(PathMediaLibrary);


            FileService.WriteFile(PathIndexFile, IndexMediaLibrary, FileDataType.IndexFile);

        }
Example #20
0
 private static void WithIndex(Action <IIndexFile> code)
 {
     using (var index = new IndexFile(INDEX_FILE))
         code.Invoke(index);
 }
Example #21
0
        /// <summary>
        /// Restores the default settings back into the CMP file.
        /// Does NOT delete .rgsp entry.
        /// </summary>
        /// <param name="race"></param>
        /// <param name="gender"></param>
        /// <param name="index"></param>
        /// <param name="modlist"></param>
        /// <returns></returns>
        internal static async Task RestoreDefaultScaling(XivSubRace race, XivGender gender, IndexFile index = null, ModList modlist = null)
        {
            var defaults = await GetScalingParameter(race, gender, true, index, modlist);

            await SetScalingParameter(defaults, index, modlist);
        }
Example #22
0
        private void I_OnEnd2(IndexFile i)
        {

            FileSystemNodePlus<MyAddittionalData> n = i.RootFileSystem.FindFirst((x) => { return x.Name.StartsWith("Summertime"); });

            ConvertionEntity s = new ConvertionEntity(i.RootFileSystem.GetFullPath(n), n.AddittionalData.Metadata.MediaMetadata);
            FFMpegMediaMetadataFlac mm = new FFMpegMediaMetadataFlac(n.AddittionalData.Metadata.MediaMetadata);
            mm.SamplingRate = SamplingRateInfo._44100;
            mm.Bit = BitInfo._24;
            ConvertionEntity d = new ConvertionEntity(SystemService.ChangeExtension(i.RootFileSystem.GetFullPath(n), "flac"),mm);
            
            
            FFmpeg.ConvertTo(s, d, true, true, 
                (status, source, dest) => 
                {
                    if (status == FFmpegStatus.Stop)
                        MessageBox.Show(source + " -> " + dest + "\r\n FINE!");
            }, 
                (percent, source, dest, error) => 
                {

            }, false);

        }
Example #23
0
 private void IdxFileMissing(IndexFile file)
 {
     _p2P.DownloadFile(file.hash);
 }