Exemplo n.º 1
0
        private void AddFile(SoftwareInfo software, string modulesPath, string file, Dictionary <string, ModuleInfo> modules)
        {
            var fileName = Path.GetFileName(file);
            var filePath = Path.Combine(modulesPath, fileName).ToLowerInvariant();

            var productName = software.Product.Name;
            var moduleName  = ModuleProvider.GetModuleName(productName, filePath);

            if (moduleName == null)
            {
                Logger.LogError("Missing module for {0}", filePath);
                moduleName = fileName;
            }

            var buffer = File.ReadAllBytes(file);

            if (!modules.TryGetValue(moduleName, out ModuleInfo moduleInfo))
            {
                moduleInfo = GetModule(software, buffer);
                modules.Add(moduleName, moduleInfo);
            }

            var hashString = HashProvider.GetHashString(buffer, HashName);

            moduleInfo.Hash.Values.Add(filePath, hashString);
        }