private LstFile LstParser(string line, CompressedIo archive, CompressedFile metadata)
        {
            var splitLine = line.Split(',');
            var updateLst = new LstFile
            {
                Source      = splitLine[0] != "0" ? splitLine[1] : splitLine[2],
                Destination = splitLine[2],
                FileSize    = ulong.Parse(splitLine[3]),
                Crc         = splitLine[4],
                Revision    = int.Parse(splitLine[5])
            };

            if (archive.GetType() == typeof(ZipArchiveIo))
            {
                var outerPath = metadata.FullName.Split('/').ToList();
                var innerPath = updateLst.Source.Replace("\\", "/").Split('/').ToList();
                outerPath.RemoveAt(outerPath.Count - 1);
                if (splitLine[0] == "0")
                {
                    outerPath.Add("data");
                }

                foreach (var item in innerPath)
                {
                    if (item == "..")
                    {
                        outerPath.RemoveAt(outerPath.Count - 1);
                    }
                    else
                    {
                        outerPath.Add(item);
                    }
                }

                var query = outerPath[0];
                outerPath.RemoveAt(0);
                foreach (var item in outerPath)
                {
                    if (item != "")
                    {
                        query += "/" + item;
                    }
                }
                updateLst.SrcFileMetadata = archive.FindFile(query);
            }
            else
            {
                var outerPath = metadata.FullName.Replace("\\", "/").Split('/').ToList();
                var innerPath = updateLst.Source.Replace("\\", "/").Split('/').ToList();
                outerPath.RemoveAt(outerPath.Count - 1);
                if (splitLine[0] == "0")
                {
                    outerPath.Add("data");
                }

                foreach (var item in innerPath)
                {
                    if (item == "..")
                    {
                        outerPath.RemoveAt(outerPath.Count - 1);
                    }
                    else
                    {
                        outerPath.Add(item);
                    }
                }

                var query = "";
                if (archive.GetType() == typeof(RawDir))
                {
                    query = outerPath[0];
                    outerPath.RemoveAt(0);
                }
                foreach (var item in outerPath)
                {
                    if (item != "")
                    {
                        query += "\\" + item;
                    }
                }
                updateLst.SrcFileMetadata = archive.FindFile(query);
            }

            return(updateLst);
        }
Пример #2
0
 public void Add_File(LstFile meta)
 {
     FileList.Add(meta);
 }