Exemplo n.º 1
0
        /// <summary>
        /// Creates backup copy of replaced packed file
        /// </summary>
        /// <param name="bnkFilePath"></param>
        /// <param name="packedFileName"></param>
        /// <param name="backupFolder"></param>
        private static void _BackupFile(string bnkFilePath, string packedFileName, string backupFolder)
        {
            FileInfo fi = new FileInfo(bnkFilePath);
            // BUG_84: suffix added to folder
            string backupSubFolder     = string.Concat(fi.Name, _SUFFIX_PACKED);
            string destinationFileName = string.Concat(backupFolder, @"\", backupSubFolder, @"\", packedFileName);

            // If backup file already exists, it is kept
            if (!File.Exists(destinationFileName))
            {
                // Loading Bnk to extract file
                BNK bnk = TduFile.GetFile(bnkFilePath) as BNK;

                if (bnk == null || !bnk.Exists)
                {
                    throw new Exception("Invalid BNK file: " + bnkFilePath);
                }

                fi = new FileInfo(destinationFileName);

                if (fi.Directory == null)
                {
                    throw new Exception("Invalid file name: " + destinationFileName);
                }

                if (!Directory.Exists(fi.Directory.FullName))
                {
                    Directory.CreateDirectory(fi.Directory.FullName);
                }

                string packedFilePath = bnk.GetPackedFilesPaths(packedFileName)[0];

                bnk.ExtractPackedFile(packedFilePath, destinationFileName, false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prépare le chargement d'une catégorie depuis la base de données courante
        /// </summary>
        /// <param name="category">Type de données recherché</param>
        /// <param name="culture">Code pays</param>
        private void _LoadFromCurrentDatabase(DB.Topic category, DB.Culture culture)
        {
            // Localisation du fichier BNK
            string bnkPath = Program.ApplicationSettings.TduMainFolder + LibraryConstants.FOLDER_DB + DB.GetBNKFileName(culture);
            BNK    bnk     = TduFile.GetFile(bnkPath) as BNK;

            if (bnk != null && bnk.Exists)
            {
                string fileName = DB.GetFileName(culture, category);
                string filePath = bnk.GetPackedFilesPaths(fileName)[0];

                // EVO_91: using edit support from ModdingLibrary
                EditHelper.Task currentTask = EditHelper.Instance.AddTask(bnk, filePath, true);

                _EditedFile = currentTask.extractedFile;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the whole specified topic for edit mode and returns corresponding TduFiles and EditTasks
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="culture"></param>
        /// <param name="bnkFile"></param>
        /// <param name="rBnkFile"></param>
        /// <param name="returnedTasks"></param>
        /// <returns></returns>
        public static TduFile[] LoadTopicForEdit(DB.Topic topic, DB.Culture culture, BNK bnkFile, BNK rBnkFile, out EditHelper.Task[] returnedTasks)
        {
            TduFile[] returnedFiles = new TduFile[2];

            returnedTasks = new EditHelper.Task[2];

            if (bnkFile != null && bnkFile.Exists)
            {
                // Getting files
                string dbFilePath = bnkFile.GetPackedFilesPaths(DB.GetFileName(DB.Culture.Global, topic))[0];

                returnedTasks[0] = EditHelper.Instance.AddTask(bnkFile, dbFilePath, true);

                if (culture != DB.Culture.Global &&
                    rBnkFile != null && rBnkFile.Exists)
                {
                    string dbrFilePath = rBnkFile.GetPackedFilesPaths(DB.GetFileName(culture, topic))[0];

                    returnedTasks[1] = EditHelper.Instance.AddTask(rBnkFile, dbrFilePath, true);
                }

                // Loading these files
                DB main = TduFile.GetFile(returnedTasks[0].extractedFile) as DB;

                if (main == null || !main.Exists)
                {
                    throw new Exception(topic + " main database loading failure.");
                }
                returnedFiles[0] = main;

                // Resource (optional)
                if (returnedTasks[1].isValid)
                {
                    DBResource resource = TduFile.GetFile(returnedTasks[1].extractedFile) as DBResource;

                    if (resource == null || !resource.Exists)
                    {
                        throw new Exception(string.Concat(topic, "-", culture, " resource database loading failure."));
                    }
                    returnedFiles[1] = resource;
                }
            }

            return(returnedFiles);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Replaces packed file in TDU installed files by previous backup
        /// </summary>
        /// <param name="bnkFilePath"></param>
        /// <param name="packedFileName"></param>
        /// <param name="backupFolder"></param>
        private static void _UninstallPackedFile(string bnkFilePath, string packedFileName, string backupFolder)
        {
            FileInfo fi = new FileInfo(bnkFilePath);
            // BUG_84: suffix added to folder
            string backupSubFolder = string.Concat(fi.Name, InstallPackedFileI._SUFFIX_PACKED);
            string backupFileName  = string.Concat(backupFolder, @"\", backupSubFolder, @"\", packedFileName);

            // Replaces file in BNK
            BNK bnk = TduFile.GetFile(bnkFilePath) as BNK;

            if (bnk == null || !bnk.Exists)
            {
                throw new Exception("Invalid BNK file: " + bnkFilePath);
            }

            string packedFilePath = bnk.GetPackedFilesPaths(packedFileName)[0];

            bnk.ReplacePackedFile(packedFilePath, backupFileName);
        }
Exemplo n.º 5
0
        static BankInfoOutputObject GetBankInfoOutput(BNK bankFile)
        {
            var outputObject = new BankInfoOutputObject((int)bankFile.Size, (int)bankFile.Year);

            var packedFilesInformations = new List <PackedFileInfoOutputObject>();

            foreach (var packedFilePath in bankFile.GetPackedFilesPaths(null))
            {
                var packedFileShortName       = bankFile.GetPackedFileName(packedFilePath);
                var packedFileSize            = bankFile.GetPackedFileSize(packedFilePath);
                var packedFileTypeDescription = bankFile.GetPackedFileTypeDescription(packedFilePath);

                var packedFilesInfo = new PackedFileInfoOutputObject(packedFileShortName, packedFilePath, packedFileSize, packedFileTypeDescription);
                packedFilesInformations.Add(packedFilesInfo);
            }

            outputObject.PackedFiles.AddRange(packedFilesInformations);

            return(outputObject);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Loads the whole specified topic in current database for read-only mode
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="culture"></param>
        /// <returns>Array of database loaded TduFile. Index 0 is the main (encrypted) file, index 1 is the resource one</returns>
        public static TduFile[] LoadTopicForReadOnly(DB.Topic topic, DB.Culture culture)
        {
            TduFile[] returnedFiles = new TduFile[2];

            // Loading BNKs
            string databaseFolder  = LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database);
            string mainBnkFile     = string.Concat(databaseFolder, DB.GetBNKFileName(DB.Culture.Global));
            string resourceBnkFile = string.Concat(databaseFolder, DB.GetBNKFileName(culture));
            BNK    mainBnk         = TduFile.GetFile(mainBnkFile) as BNK;
            BNK    resourceBnk     = TduFile.GetFile(resourceBnkFile) as BNK;

            // Getting read-only files
            if (mainBnk != null && resourceBnk != null)
            {
                string dbPackedFileName = DB.GetFileName(DB.Culture.Global, topic);
                string fileName         =
                    EditHelper.Instance.PrepareFile(mainBnk, mainBnk.GetPackedFilesPaths(dbPackedFileName)[0]);
                string dbrPackedFileName = DB.GetFileName(culture, topic);
                string resourceFileName  =
                    EditHelper.Instance.PrepareFile(resourceBnk, resourceBnk.GetPackedFilesPaths(dbrPackedFileName)[0]);

                // Loading these files
                DB         main     = TduFile.GetFile(fileName) as DB;
                DBResource resource = TduFile.GetFile(resourceFileName) as DBResource;

                if (main == null || !main.Exists)
                {
                    throw new Exception(topic + " main database failure.");
                }
                if (resource == null || !resource.Exists)
                {
                    throw new Exception(string.Concat(topic, "-", culture, " resource database failure."));
                }

                // Filling array
                returnedFiles[0] = main;
                returnedFiles[1] = resource;
            }

            return(returnedFiles);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles database loading
        /// </summary>
        private void _LoadDatabase()
        {
            DB.Culture currentCulture      = Program.ApplicationSettings.GetCurrentCulture();
            string     resourceBNKFileName = DB.GetBNKFileName(currentCulture);
            BNK        resourceBNK         = TduFile.GetFile(Tools.TduPath + LibraryConstants.FOLDER_DB + resourceBNKFileName) as BNK;

            if (resourceBNK != null)
            {
                // Extracting Houses resource
                string packedFileName = DB.GetFileName(currentCulture, DB.Topic.Houses);
                string packedFilePath = resourceBNK.GetPackedFilesPaths(packedFileName)[0];
                string tempLocation   = File2.SetTemporaryFolder(null, LibraryConstants.FOLDER_TEMP, true);

                resourceBNK.ExtractPackedFile(packedFilePath, tempLocation, true);

                // Loading resource
                _HousesResource = TduFile.GetFile(tempLocation + @"\" + packedFileName) as DBResource;

                if (_HousesResource == null)
                {
                    throw new Exception("Error while loading database resources (Houses) !");
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Checking parameter
            string vehicleRef = _GetParameter(PatchInstructionParameter.ParameterName.vehicleDatabaseId);

            // Modifying corresponding topic
            EditHelper.Task dbTask      = new EditHelper.Task();
            string          bnkFilePath = "";

            try
            {
                string dbFileName = null;

                // 1. Creating edit task
                try
                {
                    bnkFilePath = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(DB.Culture.Global));

                    BNK databaseBNK = TduFile.GetFile(bnkFilePath) as BNK;

                    if (databaseBNK != null)
                    {
                        dbFileName = DB.GetFileName(DB.Culture.Global, DB.Topic.CarShops);
                        dbTask     = EditHelper.Instance.AddTask(databaseBNK, databaseBNK.GetPackedFilesPaths(dbFileName)[0], true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to create edit task on BNK file: " + bnkFilePath, ex);
                }

                // 2. Getting TduFile
                DB db;

                try
                {
                    db = TduFile.GetFile(dbTask.extractedFile) as DB;

                    if (db == null || !db.Exists)
                    {
                        throw new Exception("Extracted db file not found!");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to gain access to DB contents: " + dbFileName, ex);
                }

                // 3. Setting values in DB file
                DatabaseHelper.RemoveValueFromAnyColumn(db, vehicleRef, DatabaseConstants.COMPACT1_PHYSICS_DB_RESID);

                Log.Info("Entry updating completed: " + vehicleRef);

                // 4. Saving
                try
                {
                    db.Save();
                    EditHelper.Instance.ApplyChanges(dbTask);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save BNK file: " + bnkFilePath, ex);
                }
            }
            finally
            {
                // Cleaning up
                EditHelper.Instance.RemoveTask(dbTask);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Parameters
            string vehicleName = _GetParameter(PatchInstructionParameter.ParameterName.slotFullName);
            string cameraId    = _GetParameter(PatchInstructionParameter.ParameterName.cameraIKIdentifier);

            // Loading reference
            VehicleSlotsHelper.InitReference(PatchHelper.CurrentPath);

            // Checking validity
            if (!VehicleSlotsHelper.SlotReference.ContainsKey(vehicleName))
            {
                throw new Exception("Specified vehicle name is not supported: " + vehicleName);
            }

            if (!VehicleSlotsHelper.CamReference.ContainsKey(cameraId))
            {
                throw new Exception("Specified camera identifier is not supported: " + cameraId);
            }

            // Edit task
            EditHelper.Task task = new EditHelper.Task();

            try
            {
                try
                {
                    string bnkFileName = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(DB.Culture.Global));
                    BNK    dbBnkFile   = TduFile.GetFile(bnkFileName) as BNK;

                    if (dbBnkFile != null)
                    {
                        string dbFilePath =
                            dbBnkFile.GetPackedFilesPaths(DB.GetFileName(DB.Culture.Global, DB.Topic.CarPhysicsData))[0];

                        task =
                            EditHelper.Instance.AddTask(dbBnkFile, dbFilePath, true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to get TDU database contents in DB.BNK.", ex);
                }

                // Opens packed file
                DB physicsDB = TduFile.GetFile(task.extractedFile) as DB;

                if (physicsDB == null)
                {
                    throw new Exception("Unable to get CarPhysicsData information.");
                }

                // Changes camera
                try
                {
                    string vehicleRef = VehicleSlotsHelper.SlotReference[vehicleName];

                    VehicleSlotsHelper.ChangeCameraById(vehicleRef, cameraId, physicsDB);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to use new camera set: " + cameraId + " for " + vehicleName, ex);
                }

                // Saving
                try
                {
                    physicsDB.Save();
                    EditHelper.Instance.ApplyChanges(task);
                    EditHelper.Instance.RemoveTask(task);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save and replace file in BNK.", ex);
                }
            }
            finally
            {
                EditHelper.Instance.RemoveTask(task);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Checking parameter
            string vehicleRef   = _GetParameter(PatchInstructionParameter.ParameterName.vehicleDatabaseId);
            string spotAndSlots = _GetParameter(PatchInstructionParameter.ParameterName.resourceValues);

            // Modifying corresponding topic
            EditHelper.Task dbTask      = new EditHelper.Task();
            string          bnkFilePath = "";

            try
            {
                string dbFileName = null;

                // 1. Creating edit task
                try
                {
                    bnkFilePath = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(DB.Culture.Global));

                    BNK databaseBNK = TduFile.GetFile(bnkFilePath) as BNK;

                    if (databaseBNK != null)
                    {
                        dbFileName = DB.GetFileName(DB.Culture.Global, DB.Topic.CarShops);
                        dbTask     = EditHelper.Instance.AddTask(databaseBNK, databaseBNK.GetPackedFilesPaths(dbFileName)[0], true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to create edit task on BNK file: " + bnkFilePath, ex);
                }

                // 2. Getting TduFile
                DB db;

                try
                {
                    db = TduFile.GetFile(dbTask.extractedFile) as DB;

                    if (db == null || !db.Exists)
                    {
                        throw new Exception("Extracted db file not found!");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to gain access to DB contents: " + dbFileName, ex);
                }

                // 3. Setting values in DB file
                // One identifier (primary key: REF)
                List <Couple <string> > couples = Tools.ParseCouples(spotAndSlots);

                // Parsing couples
                foreach (Couple <string> couple in couples)
                {
                    string   spotRef = couple.FirstValue;
                    string[] slots   = couple.SecondValue.Split(new string[] { Tools.SYMBOL_VALUE_SEPARATOR3 }, StringSplitOptions.RemoveEmptyEntries);

                    // Does id exist ?
                    if (db.EntriesByPrimaryKey.ContainsKey(spotRef))
                    {
                        // Already exists > modify it
                        foreach (string anotherSlot in slots)
                        {
                            string slotColumnName =
                                string.Format(DatabaseConstants.SLOT_CARSHOPS_PATTERN_DB_COLUMN, anotherSlot);

                            DatabaseHelper.UpdateCellFromTopicWherePrimaryKey(db, slotColumnName, spotRef, vehicleRef);
                        }

                        Log.Info("Entry updating completed for spot: " + spotRef + " - " + couple.SecondValue);
                    }
                    else
                    {
                        Log.Error("Specified location does not exist! " + spotRef, null);
                    }
                }

                Log.Info("Entry updating completed for vehicle: " + vehicleRef);

                // 4. Saving
                try
                {
                    db.Save();
                    EditHelper.Instance.ApplyChanges(dbTask);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save BNK file: " + bnkFilePath, ex);
                }
            }
            finally
            {
                // Cleaning up
                EditHelper.Instance.RemoveTask(dbTask);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Checking parameters
            string fileName = _GetParameter(PatchInstructionParameter.ParameterName.resourceFileName);
            string values   = _GetParameter(PatchInstructionParameter.ParameterName.resourceValues);

            // Modifying corresponding topic
            DB.Topic        currentTopic = (DB.Topic)Enum.Parse(typeof(DB.Topic), fileName);
            EditHelper.Task dbTask       = new EditHelper.Task();
            string          bnkFilePath  = "";

            try
            {
                string dbFileName = null;

                // 1. Creating edit task
                try
                {
                    bnkFilePath = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(DB.Culture.Global));

                    BNK databaseBNK = TduFile.GetFile(bnkFilePath) as BNK;

                    if (databaseBNK != null)
                    {
                        dbFileName = DB.GetFileName(DB.Culture.Global, currentTopic);
                        dbTask     = EditHelper.Instance.AddTask(databaseBNK, databaseBNK.GetPackedFilesPaths(dbFileName)[0], true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to create edit task on BNK file: " + bnkFilePath, ex);
                }

                // 2. Getting TduFile
                DB db;

                try
                {
                    db = TduFile.GetFile(dbTask.extractedFile) as DB;

                    if (db == null || !db.Exists)
                    {
                        throw new Exception("Extracted db file not found!");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to gain access to DB contents: " + dbFileName, ex);
                }

                // 3. Setting values in DB file
                // One identifier (primary key: REF) or 2 identifiers (2 first columns)
                List <Couple <string> > couples = Tools.ParseCouples(values);
                string[] idArray = new string[couples.Count];
                int      counter = 0;

                // Parsing couples
                foreach (Couple <string> couple in couples)
                {
                    string id    = couple.FirstValue;
                    string value = couple.SecondValue;

                    // Does id exist ?
                    if (db.EntriesByPrimaryKey.ContainsKey(id))
                    {
                        // Already exists > modify it
                        DatabaseHelper.UpdateAllCellsFromTopicWherePrimaryKey(db, id, value);

                        Log.Info("Entry updating completed: " + id + " - " + value);
                    }
                    else
                    {
                        // Does not exist > create it
                        DatabaseHelper.InsertAllCellsIntoTopic(db, value);

                        Log.Info("Entry adding completed: " + value);
                    }

                    idArray[counter++] = id;
                }

                // 4. Saving
                try
                {
                    db.Save();
                    EditHelper.Instance.ApplyChanges(dbTask);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save BNK file: " + bnkFilePath, ex);
                }
            }
            finally
            {
                // Cleaning up
                EditHelper.Instance.RemoveTask(dbTask);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Checking parameters
            string fileName = _GetParameter(PatchInstructionParameter.ParameterName.resourceFileName);
            string id       = _GetParameter(PatchInstructionParameter.ParameterName.databaseId);

            // Modifying corresponding topic
            DB.Topic        currentTopic = (DB.Topic)Enum.Parse(typeof(DB.Topic), fileName);
            EditHelper.Task dbTask       = new EditHelper.Task();
            string          bnkFilePath  = "";

            try
            {
                string dbFileName = null;

                // 1. Creating edit task
                try
                {
                    bnkFilePath = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(DB.Culture.Global));

                    BNK databaseBNK = TduFile.GetFile(bnkFilePath) as BNK;

                    if (databaseBNK != null)
                    {
                        dbFileName = DB.GetFileName(DB.Culture.Global, currentTopic);
                        dbTask     = EditHelper.Instance.AddTask(databaseBNK, databaseBNK.GetPackedFilesPaths(dbFileName)[0], true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to create edit task on BNK file: " + bnkFilePath, ex);
                }

                // 2. Getting TduFile
                DB db;

                try
                {
                    db = TduFile.GetFile(dbTask.extractedFile) as DB;

                    if (db == null || !db.Exists)
                    {
                        throw new Exception("Extracted db file not found!");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to gain access to DB contents: " + dbFileName, ex);
                }

                // 3. Removing values in DB file
                DatabaseHelper.DeleteFromTopicWhereIdentifier(db, id);

                // 4. Saving
                try
                {
                    db.Save();
                    EditHelper.Instance.ApplyChanges(dbTask);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save BNK file: " + bnkFilePath, ex);
                }
            }
            finally
            {
                // Cleaning up
                EditHelper.Instance.RemoveTask(dbTask);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Checking parameters
            string fileName = _GetParameter(PatchInstructionParameter.ParameterName.resourceFileName);
            string values   = _GetParameter(PatchInstructionParameter.ParameterName.resourceValues);

            // For each language file
            DB.Topic currentTopic = (DB.Topic)Enum.Parse(typeof(DB.Topic), fileName);

            for (int i = 0; i < 8; i++)
            {
                DB.Culture      currentCulture   = (DB.Culture)Enum.Parse(typeof(DB.Culture), i.ToString());
                EditHelper.Task resourceTask     = new EditHelper.Task();
                string          bnkFilePath      = "";
                string          resourceFileName = null;

                // 1. Creating edit task
                try
                {
                    bnkFilePath = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Database), DB.GetBNKFileName(currentCulture));

                    BNK databaseBNK = TduFile.GetFile(bnkFilePath) as BNK;

                    if (databaseBNK != null)
                    {
                        resourceFileName = DB.GetFileName(currentCulture, currentTopic);
                        resourceTask     =
                            EditHelper.Instance.AddTask(databaseBNK,
                                                        databaseBNK.GetPackedFilesPaths(resourceFileName)[0], true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to create edit task on BNK file: " + bnkFilePath, ex);
                }

                // 2. Getting TduFile
                DBResource resource;

                try
                {
                    resource = TduFile.GetFile(resourceTask.extractedFile) as DBResource;

                    if (resource == null || !resource.Exists)
                    {
                        throw new Exception("Extracted resource db file not found!");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to gain access to DB contents: " + resourceFileName, ex);
                }

                // 3. Setting values in DB file
                List <Couple <string> > couples = Tools.ParseCouples(values);

                // Parsing couples
                foreach (Couple <string> couple in couples)
                {
                    string id    = couple.FirstValue;
                    string value = couple.SecondValue;

                    // Does id exist ?
                    DBResource.Entry currentEntry = resource.GetEntryFromId(id);

                    if (currentEntry.isValid)
                    {
                        // Already exists > modify it
                        currentEntry.value = value;
                        resource.UpdateEntry(currentEntry);

                        Log.Info("Entry succesfully updated : " + id + " - " + value);
                    }
                    else
                    {
                        // Does not exist > create it
                        currentEntry.isValid = true;
                        currentEntry.id      = new ResourceIdentifier(id, currentTopic);
                        currentEntry.value   = value;
                        currentEntry.index   = resource.EntryList.Count + 1;
                        resource.InsertEntry(currentEntry);

                        Log.Info("Entry succesfully added : " + id + " - " + value);
                    }
                }

                // 4. Saving
                try
                {
                    resource.Save();
                    EditHelper.Instance.ApplyChanges(resourceTask);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save BNK file: " + bnkFilePath, ex);
                }

                // 5. Cleaning up
                EditHelper.Instance.RemoveTask(resourceTask);
            }
        }