示例#1
0
        public static UpdateModule RetrieveData(string updateModuleFilePath)
        {
            if (Directory.Exists(updateModuleFilePath))
            {
                throw new ArgumentException(string.Format(@"The path ""{0}"" was not a file path. It was a path to a directory.", updateModuleFilePath), nameof(updateModuleFilePath));
            }

            var module = new UpdateModule();

            try
            {
                var updateModuleFileType = DetectUpdateModuleFileType(updateModuleFilePath);
                if (updateModuleFileType == UpdateModuleFileType.Executable)
                {
                    module.ExecutableModuleProperties = new ExecutableUpdateModuleProperties(updateModuleFilePath);
                }

                var fileInfo = new FileInfo(updateModuleFilePath);
                module.UpdateModuleFileType    = updateModuleFileType;
                module.FileSize                = fileInfo.Length;
                module.LastModifiedDateTimeUtc = fileInfo.LastWriteTimeUtc;

                module.UpdateModuleFilePath = updateModuleFilePath;
                module.FielHash             = FileHashHelper.ComputeFileHash(updateModuleFilePath);
            }
            catch (Exception e)
            {
                throw new UpdateModuleDataRetrieveException(updateModuleFilePath, e);
            }

            return(module);
        }
示例#2
0
        private static List <UpdateModule> RetrieveUpdateModules(string innerCabWorkFolderPath)
        {
            var moduleFolderEnumOptions = new EnumerationOptions()
            {
                AttributesToSkip         = FileAttributes.Hidden | FileAttributes.System,
                BufferSize               = 0,
                IgnoreInaccessible       = false,
                MatchCasing              = MatchCasing.CaseInsensitive,
                MatchType                = MatchType.Simple,
                ReturnSpecialDirectories = false,
                RecurseSubdirectories    = false,
            };
            var moduleFileEnumOptions = new EnumerationOptions()
            {
                AttributesToSkip         = FileAttributes.Hidden | FileAttributes.System,
                BufferSize               = 0,
                IgnoreInaccessible       = false,
                MatchCasing              = MatchCasing.CaseInsensitive,
                MatchType                = MatchType.Simple,
                ReturnSpecialDirectories = false,
                RecurseSubdirectories    = true,
            };
            var updateModules = new List <UpdateModule>();

            foreach (var moduleFolderPath in Directory.EnumerateDirectories(innerCabWorkFolderPath, "*", moduleFolderEnumOptions))
            {
                foreach (var moduleFilePath in Directory.EnumerateFiles(moduleFolderPath, "*", moduleFileEnumOptions))
                {
                    updateModules.Add(UpdateModule.RetrieveData(moduleFilePath));
                }
            }
            return(updateModules);
        }