Ejemplo n.º 1
0
            private static void FillTree(FileTreeDescriptor desc, string curDirectory, GeneratorOptions config)
            {
                if (config.UseWindowsDirectorySeperator)
                    desc.Directories.Add(curDirectory + "\\");
                else
                    desc.Directories.Add(curDirectory + "/");

                DirectoryInfo d = new DirectoryInfo(curDirectory);
                foreach (var f in d.GetFiles())
                {
                    if (config.UseWindowsDirectorySeperator)
                        desc.Files.Add(new FileDescriptor(curDirectory + "\\" + f.Name, f.Length, f));
                    else
                        desc.Files.Add(new FileDescriptor(curDirectory + "/" + f.Name, f.Length, f));
                }
                foreach (var sd in d.GetDirectories())
                {
                    if (config.UseWindowsDirectorySeperator)
                        FillTree(desc, curDirectory + "\\" + sd.Name, config);
                    else
                        FillTree(desc, curDirectory + "/" + sd.Name, config);
                }
            }
Ejemplo n.º 2
0
			private static void CreateArchive(FileTreeDescriptor tree, GeneratorOptions config)
			{
				string oFNme = config.TargetArchiveFileName + "." + config.TargetFileExtension;
				if (File.Exists(oFNme))
					File.Delete(oFNme);
                Console.WriteLine("Creating '" + oFNme + "' with " + tree.Files.Count + " files");
                TotalFileCount = tree.Files.Count;
				using (var strm = new FileStream(oFNme, FileMode.Create, FileAccess.Write))
				{
					TreeCreationInit(config);

					tree.Files.Sort(
					(a, b) =>
					{
						int ap = GetFilePriority(a.SourceFile);
						int bp = GetFilePriority(b.SourceFile);
						if (ap > bp)
							return 1;
						if (ap < bp)
							return -1;
						int c = StringComparer.CurrentCultureIgnoreCase.Compare(a.SourceFile.Name, b.SourceFile.Name);
						if (c == 0)
							return StringComparer.CurrentCultureIgnoreCase.Compare(a.FullName, b.FullName);
						return c;
					});

					foreach (var v in tree.Files)
					{
                        WriteStartAddingFile(v);
						v.FileOffset = AddFile(strm, v.SourceFile, config, v);
					}

					TreeCreationFinish();
				}
			}
Ejemplo n.º 3
0
			public static FileTreeDescriptor GetTree(GeneratorOptions config)
			{
				var desc = new FileTreeDescriptor();
				Directory.SetCurrentDirectory("Data");
				DirectoryInfo d = new DirectoryInfo("./");
				foreach (var sd in d.GetDirectories())
				{
					FillTree(desc, sd.Name, config);
				}
				CreateArchive(desc, config);
				Directory.SetCurrentDirectory("../");
				return desc;
			}