Пример #1
0
        protected virtual void ReadIncludedFiles(PrimitiveReader reader)
        {
            bool filesIncluded      = reader.ReadUInt32() != 0;
            bool esOnlyDataIncluded = reader.ReadUInt32() != 0;

            if (esOnlyDataIncluded)
            {
                byte[] esdata = reader.ReadBytes(396);
                string path   = OriginalFilename;
                path = Path.GetFileName(path);
                path = Path.ChangeExtension(path, "esbin");
                path = Path.Combine("ESDATA", path);
                if (!Directory.Exists("ESDATA"))
                {
                    Directory.CreateDirectory("ESDATA");
                }
                File.WriteAllBytes(path, esdata);
            }
            if (filesIncluded)
            {
                uint           filesCount = reader.ReadUInt32();
                IncludedFile[] files      = new IncludedFile[(int)filesCount];
                for (int i = 0; i < filesCount; i++)
                {
                    IncludedFile file = new IncludedFile();
                    file.Filename = Utils.ReadUInt32LengthPrefixedString(reader);
                    file.Text     = Utils.ReadUInt32LengthPrefixedString(reader);
                    files[i]      = file;
                }
            }
            if (esOnlyDataIncluded)
            {
                //System.Diagnostics.Debug.WriteLine( reader.Stream.Position + "," + reader.Stream.Length );
            }
        }
Пример #2
0
 private static void SetUpRangeTranslators([NotNull] IncludedFile file)
 {
     file.DocumentRangeTranslator = new T4DocumentRangeTranslator(file);
     foreach (var include in file.IncludedFilesEnumerable.Cast <IncludedFile>())
     {
         SetUpRangeTranslators(include);
     }
 }
Пример #3
0
        private CompositeElement BuildIncludedT4Tree([NotNull] IPsiSourceFile target)
        {
            var lexer = LexerSelector.SelectLexer(target);
            // We need to parse File here, not IncludedFile,
            // because File makes some important error recovery and token reinsertion
            var parser = new T4Parser(lexer, target, PhysicalSourceFile, LexerSelector, Context);

            return(IncludedFile.FromOtherNode(parser.ParseFileWithoutCleanup()));
        }
Пример #4
0
        private CompositeElement BuildIncludedT4Tree([NotNull] IPsiSourceFile target)
        {
            var languageService = T4Language.Instance.LanguageService().NotNull();
            var lexer           = languageService.GetPrimaryLexerFactory().CreateLexer(target.Document.Buffer);

            // We need to parse File here, not IncludedFile,
            // because File makes some important error recovery and token reinsertion
            return(IncludedFile.FromOtherNode(new T4Parser(lexer, target, PhysicalSourceFile, Context)
                                              .ParseFileWithoutCleanup()));
        }
        public IEnumerable <IncludedFile> ReadStaticFilesDetails(XmlNode rootElement)
        {
            if (rootElement == null)
            {
                throw new DeserialisationException("Could not find StaticFiles node");
            }

            List <IncludedFile> paths = new List <IncludedFile>();

            var fileNodes = rootElement.SelectNodes("StaticFile");

            if (fileNodes != null)
            {
                foreach (XmlNode node in fileNodes)
                {
                    //					string displayName = node.Attributes["displayname"].Value;
                    var file = new IncludedFile(node.Attributes["filename"].Value);
                    paths.Add(file);
                }
            }
            return(paths);
        }
Пример #6
0
        protected override void ProcessResource(IncludedFileCollection aIncludes)
        {
            var document = LoadXml(Filenames.IncludedFiles + ".xml");

            if (document != null)
            {
                OnCategoryProcessing(ResourceTypes.IncludedFiles);

                foreach (var element in document.Elements("File"))
                {
                    var include = new IncludedFile();

                    include.Filename              = GetElement(element, "Filename").Value;
                    include.FilePath              = GetElement(element, "FilePath").Value;
                    include.OriginalFileSelected  = GetElementValue <bool>(element, "OriginalFileSelected");
                    include.OriginalFileSize      = GetElementValue <int>(element, "OriginalFileSize");
                    include.FileStored            = GetElementValue <bool>(element, "FileStored");
                    include.ExportType            = GetElementValue <FileExportTypes>(element, "ExportType");
                    include.ExportDirectory       = GetElement(element, "ExportDirectory").Value;
                    include.OverwriteExistingFile = GetElementValue <bool>(element, "OverwriteExistingFile");
                    include.FreeMemoryAfterExport = GetElementValue <bool>(element, "FreeMemoryAfterExport");
                    include.RemoveAtGameEnd       = GetElementValue <bool>(element, "RemoveAtGameEnd");

                    var data = LoadToMemory(GetElement(element, "FileCopyPath").Value);

                    if (data != null)
                    {
                        include.FileStored = true;
                        include.FileData   = data;
                    } // ?

                    aIncludes.Add(include);
                    OnAbortProcessingCallback();
                }

                OnCategoryProcessed(ResourceTypes.IncludedFiles);
            }
        }