Ejemplo n.º 1
0
        public PatchCreator AddIgnoredPath(string ignoredPath)
        {
            if (ignoredPath != null)
            {
                ignoredPath = ignoredPath.Trim().Replace(PatchUtils.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            }

            if (!string.IsNullOrEmpty(ignoredPath))
            {
                if (ignoredPaths.Add(ignoredPath))
                {
                    ignoredPathsRegex.Add(PatchUtils.WildcardToRegex(ignoredPath));
                }
            }

            return(this);
        }
Ejemplo n.º 2
0
        /// <exception cref = "DirectoryNotFoundException">Root path does not exist</exception>
        /// <exception cref = "UnauthorizedAccessException">A path needs admin priviledges to write</exception>
        /// <exception cref = "IOException">Output path is not empty</exception>
        /// <exception cref = "ArgumentException">An argument is empty</exception>
        /// <exception cref = "FormatException">Version is invalid</exception>
        public PatchCreator(string rootPath, string outputPath, string projectName, VersionCode version)
        {
            rootPath    = rootPath.Trim();
            outputPath  = outputPath.Trim();
            projectName = projectName.Trim();

            if (string.IsNullOrEmpty(rootPath))
            {
                throw new ArgumentException(Localization.Get(StringId.E_XCanNotBeEmpty, "'rootPath'"));
            }

            if (string.IsNullOrEmpty(outputPath))
            {
                throw new ArgumentException(Localization.Get(StringId.E_XCanNotBeEmpty, "'outputPath'"));
            }

            if (string.IsNullOrEmpty(projectName))
            {
                throw new ArgumentException(Localization.Get(StringId.E_XCanNotBeEmpty, "'projectName'"));
            }

            if (!version.IsValid)
            {
                throw new FormatException(Localization.Get(StringId.E_VersionCodeXIsInvalid, version));
            }

            if (!Directory.Exists(rootPath))
            {
                throw new DirectoryNotFoundException(Localization.Get(StringId.E_XDoesNotExist, rootPath));
            }

            if (!PatchUtils.CheckWriteAccessToFolder(rootPath))
            {
                throw new UnauthorizedAccessException(Localization.Get(StringId.E_AccessToXIsForbiddenRunInAdminMode, rootPath));
            }

            if (!PatchUtils.CheckWriteAccessToFolder(outputPath))
            {
                throw new UnauthorizedAccessException(Localization.Get(StringId.E_AccessToXIsForbiddenRunInAdminMode, outputPath));
            }

            if (Directory.Exists(outputPath))
            {
                if (Directory.GetFileSystemEntries(outputPath).Length > 0)
                {
                    throw new IOException(Localization.Get(StringId.E_DirectoryXIsNotEmpty, outputPath));
                }
            }

            Localization.Get(StringId.Done);               // Force the localization system to be initialized with the current culture/language

            previousPatchFilesRoot = null;
            previousVersionInfo    = null;
            dontCreatePatchFilesForUnchangedFiles = false;

            generateRepairPatch    = true;
            generateInstallerPatch = true;

            previousVersionRoot = null;
            diffQuality         = 0;

            this.previousVersion = null;
            this.version         = version;

            this.rootPath    = PatchUtils.GetPathWithTrailingSeparatorChar(rootPath);
            this.outputPath  = PatchUtils.GetPathWithTrailingSeparatorChar(outputPath);
            this.projectName = projectName;

            repairPatchOutputPath      = this.outputPath + PatchParameters.REPAIR_PATCH_DIRECTORY + Path.DirectorySeparatorChar;
            installerPatchOutputPath   = this.outputPath + PatchParameters.INSTALLER_PATCH_DIRECTORY + Path.DirectorySeparatorChar;
            incrementalPatchOutputPath = this.outputPath + PatchParameters.INCREMENTAL_PATCH_DIRECTORY + Path.DirectorySeparatorChar;
            incrementalPatchTempPath   = this.outputPath + "Temp" + Path.DirectorySeparatorChar;

            ignoredPaths      = new HashSet <string>();
            ignoredPathsRegex = new List <Regex>()
            {
                PatchUtils.WildcardToRegex("*" + PatchParameters.VERSION_HOLDER_FILENAME_POSTFIX), // Ignore any version holder files
                PatchUtils.WildcardToRegex("*" + PatchParameters.LOG_FILE_NAME)                    // Or log files
            };

            compressionFormatRepairPatch      = CompressionFormat.LZMA;
            compressionFormatInstallerPatch   = CompressionFormat.LZMA;
            compressionFormatIncrementalPatch = CompressionFormat.LZMA;

            baseDownloadURL     = "";
            maintenanceCheckURL = "";

            logs = new Queue <string>();

            cancel     = false;
            silentMode = false;

            IsRunning = false;
            Result    = PatchResult.Failed;
        }
Ejemplo n.º 3
0
        /// <exception cref = "DirectoryNotFoundException">Root path does not exist</exception>
        /// <exception cref = "UnauthorizedAccessException">A path needs admin priviledges to write</exception>
        /// <exception cref = "IOException">Output path is not empty</exception>
        /// <exception cref = "ArgumentException">An argument is empty</exception>
        /// <exception cref = "FormatException">Version is invalid</exception>
        public PatchCreator(string rootPath, string outputPath, string projectName, VersionCode version)
        {
            rootPath    = rootPath.Trim();
            outputPath  = outputPath.Trim();
            projectName = projectName.Trim();

            if (string.IsNullOrEmpty(rootPath))
            {
                throw new ArgumentException(Localization.Get(StringId.E_XCanNotBeEmpty, "'rootPath'"));
            }

            if (string.IsNullOrEmpty(outputPath))
            {
                throw new ArgumentException(Localization.Get(StringId.E_XCanNotBeEmpty, "'outputPath'"));
            }

            if (string.IsNullOrEmpty(projectName))
            {
                throw new ArgumentException(Localization.Get(StringId.E_XCanNotBeEmpty, "'projectName'"));
            }

            if (!version.IsValid)
            {
                throw new FormatException(Localization.Get(StringId.E_VersionCodeXIsInvalid, version));
            }

            if (!Directory.Exists(rootPath))
            {
                throw new DirectoryNotFoundException(Localization.Get(StringId.E_XDoesNotExist, rootPath));
            }

            if (!PatchUtils.CheckWriteAccessToFolder(rootPath))
            {
                throw new UnauthorizedAccessException(Localization.Get(StringId.E_AccessToXIsForbiddenRunInAdminMode, rootPath));
            }

            if (!PatchUtils.CheckWriteAccessToFolder(outputPath))
            {
                throw new UnauthorizedAccessException(Localization.Get(StringId.E_AccessToXIsForbiddenRunInAdminMode, outputPath));
            }

            if (Directory.Exists(outputPath))
            {
                if (Directory.GetFiles(outputPath).Length > 0 || Directory.GetDirectories(outputPath).Length > 0)
                {
                    throw new IOException(Localization.Get(StringId.E_DirectoryXIsNotEmpty, outputPath));
                }
            }

            previousVersionRoot = null;
            generateRepairPatch = false;

            this.previousVersion = null;
            this.version         = version;

            this.rootPath    = PatchUtils.GetPathWithTrailingSeparatorChar(rootPath);
            this.outputPath  = PatchUtils.GetPathWithTrailingSeparatorChar(outputPath);
            this.projectName = projectName;

            repairPatchOutputPath      = this.outputPath + PatchParameters.REPAIR_PATCH_DIRECTORY + Path.DirectorySeparatorChar;
            incrementalPatchOutputPath = this.outputPath + PatchParameters.INCREMENTAL_PATCH_DIRECTORY + Path.DirectorySeparatorChar;
            incrementalPatchTempPath   = this.outputPath + "Temp" + Path.DirectorySeparatorChar;

            ignoredPaths      = new HashSet <string>();
            ignoredPathsRegex = new List <Regex>()
            {
                PatchUtils.WildcardToRegex("*" + PatchParameters.VERSION_HOLDER_FILENAME_POSTFIX)
            };                                                                                                                                         // Ignore any version holder files

            logs = new Queue <string>();

            cancel     = false;
            silentMode = false;

            IsRunning = false;
            Result    = PatchResult.Failed;
        }