protected YaffsDirectory GetComponentDirectory(int CellId, ModuleProject Module)
        {
            FileElementsFactory fsFactory = GetFilesystemFactory(Module.FirmwareInformation.ReleaseDate);
            string directoryName = GetModuleDirectoryName(CellId, Module);

            YaffsDirectory componentRoot = fsFactory.CreateDirectory(directoryName);

            FirmwareFile attributesFile = Module.FirmwareContent.Files.FirstOrDefault(f => f.RelativePath == "attributes.xml");
            IDictionary<string, int> fileModes;
            if (attributesFile != null)
            {
                XDocument attributes = XDocument.Load(new MemoryStream(attributesFile.Content));
                fileModes = attributes.Root.Elements("SetPremissions")
                                      .ToDictionary(XPremission => XPremission.Attribute("File").Value,
                                                    XPremission => int.Parse(XPremission.Attribute("Premissions").Value, NumberStyles.HexNumber));
            }
            else
                fileModes = new Dictionary<string, int>();

            foreach (FirmwareFile file in Module.FirmwareContent.Files)
            {
                string fileName = FileSystemExplorer.GetFileName(file.RelativePath);
                int customFileMode;
                YaffsFile yaffsFile = fileModes.TryGetValue(file.RelativePath, out customFileMode)
                                          ? fsFactory.CreateFile(fileName, customFileMode, file.Content)
                                          : fsFactory.CreateFile(fileName, file.Content);

                componentRoot.Put(fsFactory, FileSystemExplorer.GetPath(file.RelativePath), yaffsFile);
            }

            return componentRoot;
        }
 /// <summary>Формирует список FUDP-свойств, связанных с программным модулем</summary>
 /// <param name="Project">Проект</param>
 public IEnumerable<ParamRecord> GetModuleProperties(ModuleProject Project)
 {
     return new List<ParamRecord>
            {
                // Информация о прошивке
                new ParamRecord(1, Project.FirmwareInformation.FirmwareVersion.Major),
                new ParamRecord(2, Project.FirmwareInformation.FirmwareVersion.Minor),
                new ParamRecord(3, (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds),
                new ParamRecord(6, Project.FirmwareContent.Files.Select(f => FudpCrc.CalcCrc(f.Content)).Aggregate((res, fcs) => (ushort)(res ^ fcs))),
                new ParamRecord(7, _stringEncoder.Encode(Project.FirmwareInformation.FirmwareVersionLabel))
            };
 }
 protected string GetModuleDirectoryName(int CellId, ModuleProject Module)
 {
     return _indexHelper.GetModule(CellId, Module.Information.ModuleId).CustomProperties["directory-name"];
 }
 public SoftwarePropertiesProvider(ModuleProject Project, IStringEncoder StringEncoder, IChecksumProvider ChecksumProvider)
 {
     _project = Project;
     _stringEncoder = StringEncoder;
     _checksumProvider = ChecksumProvider;
 }