Exemplo n.º 1
0
        public async Task ReadArcPau(string inArc, string parName, string componentName)
        {
            using (ArcFile arcFile = new ArcFile(inArc))
            {
                using (EntryStack entryStack = await arcFile.GetEntryRecursive(parName))
                {
                    using UIComponent component = await UIComponent.CreateUIComponent(await entryStack.Entry.GetData());

                    using UISubcomponent uIComponent = component[0];
                }
            }
        }
Exemplo n.º 2
0
        public async Task WriteXlsxTest(string xlsxName, string arcName, string commuList)
        {
            using CommuToXlsx commu         = new CommuToXlsx(xlsxName, true);
            using StreamReader streamReader = new StreamReader(commuList);
            using ArcFile arcFile           = new ArcFile(arcName);
            while (!streamReader.EndOfStream)
            {
                string fileName = streamReader.ReadLine();
                using EntryStack entryStack = await arcFile.GetEntryRecursive(fileName);

                ContainerEntry entry = entryStack.Entry;
                using Stream memStream = await entry.GetData();

                commu.GetAndWriteCommu(memStream, fileName);
            }
        }
Exemplo n.º 3
0
        private async Task <EntryStack> GetEntryRecursive(string fileName, EntryStack stack)
        {
            int parIndex = fileName.IndexOf("_par/");
            int ptaIndex = fileName.IndexOf("_pta/");
            int index;

            if (parIndex == -1)
            {
                index = ptaIndex;
            }
            else if (ptaIndex == -1)
            {
                index = parIndex;
            }
            else
            {
                index = Math.Min(parIndex, ptaIndex);
            }

            if (index == -1)
            {
                ContainerEntry entry = GetEntry(fileName);
                if (entry == null)
                {
                    stack.Dispose();
                    return(null);
                }
                stack.Entry = entry;
                return(stack);
            }
            else
            {
                ContainerEntry entry = GetEntry(fileName.Substring(0, index) + '.' + fileName.Substring(index + 1, 3));
                if (entry == null)
                {
                    stack.Dispose();
                    return(null);
                }
                Stream stream = await entry.GetData();

                stack.Push(stream);
                ParFile parFile = new ParFile(stream);
                stack.Push(parFile);
                return(await parFile.GetEntryRecursive(fileName.Substring(index + 5)));
            }
        }
Exemplo n.º 4
0
        public async Task GetEntryRecursiveAndWriteToFile(string filename, string entryFilepath, string expectedFile)
        {
            using ArcFile arcFile  = new ArcFile(filename);
            using EntryStack stack = await arcFile.GetEntryRecursive(entryFilepath);

            if (stack == null)
            {
                Assert.Fail("Entry not found.");
            }
            using (Stream stream = await stack.Entry.GetData())
            {
                using FileStream fileStream = new FileStream("temp.dat", FileMode.Create, FileAccess.Write);
                stream.CopyTo(fileStream);
            }
            bool eq = Compare.CompareFiles(expectedFile, "temp.dat");

            File.Delete("temp.dat");
            Assert.IsTrue(eq);
        }
Exemplo n.º 5
0
        public async Task WritePau(string inArc, string parName, string outputName)
        {
            using (ArcFile arcFile = new ArcFile(inArc))
            {
                using (EntryStack entryStack = await arcFile.GetEntryRecursive(parName))
                {
                    using UIComponent component = await UIComponent.CreateUIComponent(await entryStack.Entry.GetData());

                    using UISubcomponent uIComponent = component[0];

                    using (FileStream outStream = new FileStream("temp.pau", FileMode.Create, FileAccess.Write))
                    {
                        uIComponent.WritePauStream(outStream);
                    }

                    Assert.IsTrue(Compare.CompareFiles("temp.pau", outputName));
                }
            }
        }