static void Main(string[] args) { var file = new XCatalogFile(); file.Entries.Add(new XCatalogEntry("foo/bar.txt", DateTime.Now, Encoding.Default.GetBytes("Hello World!"))); file.Entries.Add(new XCatalogEntry("foo/baz.txt", DateTime.Now.AddDays(-5), Encoding.Default.GetBytes("Hello Teapot!"))); file.Entries.Add(new XCatalogEntry("foo/empty.txt", DateTime.Now.AddDays(-5), Encoding.Default.GetBytes(""))); file.Write("testData/ext_01"); }
public void BuildModFiles(string outputPath, IEnumerable <string> filesFromDisk, string contentFileText) { var filesLeftToWrite = new List <string>(filesFromDisk); var looseFilesToWrite = filesLeftToWrite.Where(path => config.Build.CatLoosePaths.Any(regex => regex.IsMatch(path))).ToList(); foreach (var loosePath in looseFilesToWrite) { filesLeftToWrite.Remove(loosePath); } foreach (var catInfo in config.Build.Cats) { var catFile = new XCatalogFile(); var catPath = catInfo.Key; var catPatterns = catInfo.Value; var pathsForThisCat = filesLeftToWrite.Where(path => catPatterns.Any(regex => regex.IsMatch(path))).ToList(); foreach (var catItemPath in pathsForThisCat) { filesLeftToWrite.Remove(catItemPath); catFile.Entries.Add(new XCatalogEntry(catItemPath)); } var catFullPath = Path.Combine(config.Build.OutputDirectory, catPath); catFile.Write(catFullPath); } var contentPath = Path.Combine(config.Build.OutputDirectory, "content.xml"); File.WriteAllText(contentPath, contentFileText); foreach (var loosePath in looseFilesToWrite) { var fileOutputPath = Path.Combine(outputPath, loosePath); FileUtils.CopyAndCreateDirectory(loosePath, fileOutputPath, true); } }