Exemplo n.º 1
0
        private void Initialize(MoviestormPaths pMoviestormPaths, List <string> pSources, string pDescription)
        {
            string errorText;

            MoviestormPaths  = pMoviestormPaths ?? AddonPersistenceUtils.GetMoviestormPaths(out errorText);
            AddonSources     = pSources;
            Description      = pDescription;
            CatalogueVersion = CurrentCatalogueVersion;
            LastUpdate       = DateTime.Now;
        }
Exemplo n.º 2
0
        // ---------------------------------------------------------------------------------------------------

        private void pbPathsDefaults_Click(object sender, EventArgs e)
        {
            string          errorText;
            MoviestormPaths defaultMoviestormPaths = AddonPersistenceUtils.GetMoviestormPaths(out errorText);

            if (defaultMoviestormPaths == null)
            {
                MessageBox.Show(errorText, "Error determining Moviestorm folders", MessageBoxButtons.OK);
                return;
            }

            tbMoviestormInstallPath.Text  = defaultMoviestormPaths.InstallationPath;
            tbMoviestormUserDataPath.Text = defaultMoviestormPaths.UserDataPath;
        }
Exemplo n.º 3
0
        private static bool InitializationChores(string[] pArgs, out string pErrorText)
        {
            pErrorText = null;
            if (!CheckArguments(pArgs))
            {
                return(false);
            }

            _tempPath = Utils.GetTempDirectory();

            string errorText;

            Utils.ResetTempFolder(out errorText);

            _moviestormPaths = AddonPersistenceUtils.GetMoviestormPaths(out errorText);
            if (_moviestormPaths == null)
            {
                pErrorText = errorText;
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public AddonSearchCriteria(string pName, string pPublisher, bool?pInstalled, bool?pContentPack,
                                   string pLocation)
        {
            Name       = pName;
            _nameRegex = CreateMultiValuedRegex(Name);

            Publisher       = pPublisher;
            _publisherRegex = CreateMultiValuedRegex(Publisher);

            Installed   = pInstalled;
            ContentPack = pContentPack;
            Location    = pLocation?.Trim().ToLower();
            if (!string.IsNullOrEmpty(Location))
            {
                _locationRegex = new Regex($"{Location}", RegexOptions.IgnoreCase);
            }

            if (ContentPacksPath == null)
            {
                string errorText;
                ContentPacksPath = AddonPersistenceUtils.GetMoviestormPaths(out errorText)?.ContentPacksPath;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks files inside the archive
        /// </summary>
        /// <param name="pProcessingFlags">Processing flags</param>
        /// <param name="pArchiver">Archiver used to manage the archive contents</param>
        /// <param name="pArchiveEntryList">Full information about files in archive</param>
        /// <param name="pFileList">List of files inside the archive</param>
        /// <param name="pReport">Output text</param>
        /// <returns>Result of check</returns>
        private bool CheckFiles(ProcessingFlags pProcessingFlags, SevenZipArchiver pArchiver, List <ArchiveFileInfo> pArchiveEntryList, List <string> pFileList, out string pReport)
        {
            // bool reportOnlyIssues = pProcessingFlags.HasFlag(ProcessingFlags.JustReportIssues);
            // bool showAddonContents = pProcessingFlags.HasFlag(ProcessingFlags.ShowAddonContents);


            string rootTempPath = Utils.GetTempDirectory();

            pArchiver.ArchivedFilesExtract(rootTempPath, pFileList);
            string currentPath = Utils.GetExecutableDirectory();

            Directory.SetCurrentDirectory(rootTempPath);
            pReport = null;
            try
            {
                foreach (string fileName in pFileList)
                {
                    string extension =
                        Path.GetExtension(fileName)?.Trim().ToLower();

                    bool isAddonFile = false;
                    if (extension == ".addon")
                    {
                        if (fileName.ToLower() == ".addon")
                        {
                            string rootFolder;
                            if (!InsideArchive && pProcessingFlags.HasFlag(ProcessingFlags.CorrectDisguisedFiles) &&
                                IsValidAddon(pArchiveEntryList, false, out rootFolder))
                            {
                                string errorText;
                                string newAddonFile = AddonPersistenceUtils.CorrectAddonFile(pArchiver, pProcessingFlags.HasFlag(ProcessingFlags.CorrectDisguisedFilesDeleteSource), null, out errorText);
                                if (newAddonFile == null)
                                {
                                    pReport = $"   {ErrorTokenString} Possibly an Addon file disguised as an archive. Failed to restore: {errorText}";
                                    return(false);
                                }
                                pReport = $"   Addon file disguised as an archive. Restored: {Path.GetFileName(newAddonFile)}";
                                return(true);
                            }
                            else
                            {
                                pReport = $"   {ErrorTokenString} Possibly an Addon file disguised as an archive";
                                return(false);
                            }
                        }
                        if (fileName.ToLower().EndsWith(@"\.addon"))
                        {
                            string rootFolder;
                            if (!InsideArchive && pProcessingFlags.HasFlag(ProcessingFlags.CorrectDisguisedFiles) &&
                                IsValidAddon(pArchiveEntryList, true, out rootFolder))
                            {
                                string errorText;
                                string newAddonFile = AddonPersistenceUtils.CorrectAddonFile(pArchiver, pProcessingFlags.HasFlag(ProcessingFlags.CorrectDisguisedFilesDeleteSource), rootFolder, out errorText);
                                if (newAddonFile == null)
                                {
                                    pReport = $"   {ErrorTokenString} Possibly an Addon file disguised as an archive. Failed to restore: {errorText}";
                                    return(false);
                                }
                                pReport = $"   Addon file disguised as an archive. Restored: {Path.GetFileName(newAddonFile)}";
                                return(true);
                            }
                            else
                            {
                                pReport =
                                    $"   {ErrorTokenString} Possibly an Addon file disguised as an archive, with a root directory";
                                return(false);
                            }
                        }

                        isAddonFile = true;
                    }

                    string archivedPath = $"{AbsolutePath}#{fileName}";

                    IDiskEntity diskEntity =
                        isAddonFile
                        ? new DiskEntityAddon(fileName, archivedPath, ReportWriter)
                        : (IDiskEntity) new DiskEntitySketchup(fileName, archivedPath, ReportWriter);

                    diskEntity.CheckEntity(pProcessingFlags);

                    File.Delete(fileName);
                }
            }
            catch
            {
            }
            finally
            {
                Directory.SetCurrentDirectory(currentPath);
            }

            return(true);
        }