コード例 #1
0
        static int SortOffsets(PackObject p1, PackObject p2)
        {
            if (p1 is PackFile)
            {
                if (p2 is PackDir)
                {
                    return(0);
                }

                return(((PackFile)p1).offset.CompareTo(((PackFile)p2).offset));
            }
            return(0);
        }
コード例 #2
0
        bool Search(List <PackObject> list, DirectoryInfo current)
        {
            PackObject last = null;

            DirectoryInfo[] dirs = current.GetDirectories();
            for (int i = 0; i < dirs.Length; i++)
            {
                if (string.Compare(dirs[i].Name, "user", true) == 0) // ignore "user" folders
                {
                    continue;
                }

                // search all directories
                var dir = new PackDir(dirs[i]);
                list.Add(dir);

                if (!Search(list, dirs[i]))
                {
                    list.RemoveAt(list.Count - 1); // don't add empty folders
                }
                last = dir;
            }

            FileInfo[] files = current.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                // add files
                var file = new PackFile(files[i]);
                list.Add(file);
                last = file;
            }

            if (last == null)
            {
                return(false);
            }
            else
            {
                last.IsLast = true; // last item in this folder is marked
                return(true);
            }
        }
コード例 #3
0
        int ReadObjects(PacketStream header, string path, int count, int checkBytes)
        {
            while (list.Count < count)
            {
                PackObject p = PackObject.ReadNew(header, path);
                list.Add(p);

                if (p is PackDir)
                {
                    checkBytes = ReadObjects(header, Path.Combine(path, p.Name), count, checkBytes);
                }
                else
                {
                    checkBytes += ((PackFile)p).PreCheck(checkList, neededList);
                }

                if (p.IsLast)
                {
                    break;
                }
            }
            return(checkBytes);
        }