Пример #1
0
        private void bSaveWork_Click(object sender, EventArgs e)
        {
            var reg     = new AtsRegWork(true);
            var gam     = reg.Read(RegKeys.CURRENT_GAME);
            var outPath = reg.Read(RegKeys.CURRENT_ORIGINAL_FILE_EDIT_PATH);

            FsZip.CreateArchive(outPath, reg.Read(RegKeys.CURRENT_EXTRACTED_FOLDER_PATH));
            DeleteFiles.DeleteFilesOrFolders(reg.Read(RegKeys.CURRENT_EXTRACTED_FOLDER_PATH));

            tree.Nodes.Clear();

            switch (gam)
            {
            case "ATS":
                FolderCreator.CreatePublicFolders(reg.Read(AtsRegKeys.ATS_WORK));
                break;

            case "ETS":
                FolderCreator.CreatePublicFolders(reg.Read(EtsRegKeys.ETS_WORK));
                break;

            case "FS15":
                FolderCreator.CreatePublicFolders(reg.Read(Fs15RegKeys.FS15_WORK));
                break;

            case "FS17":
                FolderCreator.CreatePublicFolders(reg.Read(Fs17RegKeys.FS17_WORK));
                break;
            }
        }
Пример #2
0
        /// <summary>
        ///     Fast file move with big buffers
        /// </summary>
        /// <param name="source">Source file path</param>
        /// <param name="destination">Destination file path</param>
        /// <param name="deleteSrc">if set to <c>true</c> [delete source].</param>
        public static void FileCopy(string source, string destination, bool deleteSrc = false)
        {
            if (Equals(source, destination))
            {
                return;
            }
            if (!source.FileExists())
            {
                return;
            }
            var arrayLength = (int)Math.Pow(2, 19);
            var dataArray   = new byte[arrayLength];

            if (!destination.DirectoryName().FolderExists())
            {
                try {
                    Directory.CreateDirectory(destination.DirectoryName());
                }
                catch (Exception e) {
                    MsgBx.Msg(e.Message, "File IO ERROR");
                }
            }

            using (var fsread = new FileStream
                                    (source, FileMode.Open, FileAccess.Read, FileShare.None, arrayLength)) {
                using (var bwread = new BinaryReader(fsread)) {
                    using (var fswrite = new FileStream
                                             (destination, FileMode.Create, FileAccess.Write, FileShare.None, arrayLength)) {
                        using (var bwwrite = new BinaryWriter(fswrite)) {
                            for (;;)
                            {
                                var read = bwread.Read(dataArray, 0, arrayLength);
                                if (0 == read)
                                {
                                    break;
                                }
                                bwwrite.Write(dataArray, 0, read);
                            }
                        }
                    }
                }
            }

            if (deleteSrc)
            {
                DeleteFiles.DeleteFilesOrFolders(source, false);
            }
        }
Пример #3
0
        /// <summary>
        ///     Removes the mod.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public Dictionary <string, string> ProfileRemoveMod(string key)
        {
            var reg     = new AtsRegWork(true);
            var gam     = reg.Read(RegKeys.CURRENT_GAME);
            var profile = reg.Read(RegKeys.CURRENT_PROFILE);
            var modPath = string.Empty;

            switch (gam)
            {
            case "ATS":
                modPath = reg.Read(AtsRegKeys.ATS_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;

            case "ETS":
                modPath = reg.Read(EtsRegKeys.ETS_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;

            case "FS15":
                modPath = reg.Read(Fs15RegKeys.FS15_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;

            case "FS17":
                modPath = reg.Read(Fs17RegKeys.FS17_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;
            }

            var dic = Serializer.DeserializeDictionary(modPath);

            if (dic.Any(v => string.Equals(v.Key, key, StringComparison.OrdinalIgnoreCase)))
            {
                var mod = reg.Read(Fs17RegKeys.FS17_PROFILES) + profile + "\\" + key;
                dic.Remove(key);
                DeleteFiles.DeleteFilesOrFolders(mod);

                var ls = new ListCreator();
                ls.CreateSortedLists();
                ls.SortedFileListComplete();
                MsgBx.Msg("Operation completed successfully", "Mod Remover");
            }

            Serializer.SerializeDictionary(modPath, dic);

            return(dic);
        }
Пример #4
0
        /// <summary>
        ///     Removes a Profile
        /// </summary>
        /// <returns></returns>
        public IEnumerable <string> ProfileRemove()
        {
            var    reg     = new AtsRegWork(true);
            var    gam     = reg.Read(RegKeys.CURRENT_GAME);
            var    profile = reg.Read(RegKeys.CURRENT_PROFILE);
            string proPath;
            IEnumerable <string> proList = null;

            switch (gam)
            {
            case "ATS":
                var ldr = new AtsLoader();
                proPath = reg.Read(AtsRegKeys.ATS_PROFILES) + profile;
                DeleteFiles.DeleteFilesOrFolders(proPath);
                proList = ldr.LoadAtsProfiles();
                break;

            case "ETS":
                var edr = new EtsLoader();
                proPath = reg.Read(EtsRegKeys.ETS_PROFILES) + profile;
                DeleteFiles.DeleteFilesOrFolders(proPath);
                proList = edr.LoadEtsProfiles();
                break;

            case "FS15":
                proPath = reg.Read(Fs15RegKeys.FS15_PROFILES) + profile;
                var fs15 = new Fs15Loader();
                DeleteFiles.DeleteFilesOrFolders(proPath);
                proList = fs15.LoadFs15Profiles();
                break;

            case "FS17":
                proPath = reg.Read(Fs17RegKeys.FS17_PROFILES) + profile;
                var fs17 = new Fs15Loader();
                DeleteFiles.DeleteFilesOrFolders(proPath);
                proList = fs17.LoadFs15Profiles();
                break;
            }

            return(proList);
        }
Пример #5
0
        private void DeleteRepoMod(string pth)
        {
            var    reg = new AtsRegWork(true);
            var    gam = reg.Read(RegKeys.CURRENT_GAME);
            var    dic = Serializer.DeserializeDictionary(pth);
            var    lc  = new ListCreator();
            var    key = lstAvailableMods.SelectedItem.ToString();
            string pt;

            if (!dic.Any(v => string.Equals(v.Key, key, StringComparison.OrdinalIgnoreCase)))
            {
                return;
            }
            dic.TryGetValue(key, out pt);
            var mPth = pt + key;

            DeleteFiles.DeleteFilesOrFolders(mPth);
            lstAvailableMods.Items.Remove(key);
            lc.CreateSortedLists();
            lc.SortedFileListComplete();
            switch (gam)
            {
            case "ETS":
                EtsLoad();
                break;

            case "ATS":
                AtsLoad();
                break;

            case "FS15":
                Fs15Load();
                break;

            case "FS17":
                Fs17Load();
                CheckModCount();
                break;
            }
        }