private static KnownFileTypes GetKnownFileTypes() { var configPath = AppDomain.CurrentDomain.BaseDirectory; var known = new KnownFileTypes(); // post-build event on TFSArtifactManager copies these over known.DatabaseFileTypes.Load(Path.Combine(configPath, "DatabaseFileTypes.xml")); known.ReportFileTypes.Load(Path.Combine(configPath, "ReportFileTypes.xml")); return(known); }
public ChangesetInfo(string tfsServer, KnownFileTypes knownFileTypes) { if (string.IsNullOrWhiteSpace(tfsServer)) { throw new ArgumentNullException("tfsServer", "tfsServer is required"); } _tfs = Server.GetTfsServer(tfsServer); _versionControl = _tfs.GetService(typeof(VersionControlServer)) as VersionControlServer; _workItemStore = (WorkItemStore)_tfs.GetService(typeof(WorkItemStore)); this.Downloader = new WorkItemFileManager(knownFileTypes); }
public override void Load() { Bind <MainViewModel>().ToSelf().InSingletonScope(); Bind <ProjectArtifactsViewModel>().ToSelf().InSingletonScope(); Bind <DatabasePackagerViewModel>().ToSelf().InSingletonScope(); Bind <WorkItemSelectorViewModel>().ToSelf(); Bind <IMessageBoxService>().To <MessageBoxService>(); Bind <KnownFileTypes>().ToMethod( x => { var configPath = AppDomain.CurrentDomain.BaseDirectory; var known = new KnownFileTypes(); known.DatabaseFileTypes.Load(Path.Combine(configPath, "DatabaseFileTypes.xml")); known.ReportFileTypes.Load(Path.Combine(configPath, "ReportFileTypes.xml")); return(known); }); }
internal WorkItemFileManager(KnownFileTypes knownFileTypes) { this.KnownFileTypes = knownFileTypes; this.DeployInfo = new WorkItemDeployInfo(); this.DbFileOrderGuess = new Dictionary <string, int>(); }
public static void Main(string[] args) { bool showHelp = false; bool overwriteFiles = false; bool verbose = false; var options = new OptionSet() { { "o|overwrite", "overwrite existing files", v => overwriteFiles = v != null }, { "v|verbose", "be verbose", v => verbose = v != null }, { "h|help", "show this message and exit", v => showHelp = v != null }, }; List <string> extras; try { extras = options.Parse(args); } catch (OptionException e) { Console.Write("{0}: ", GetExecutableName()); Console.WriteLine(e.Message); Console.WriteLine("Try `{0} --help' for more information.", GetExecutableName()); return; } if (extras.Count < 1 || extras.Count > 2 || showHelp == true) { Console.WriteLine("Usage: {0} [OPTIONS]+ input_rcf [output_dir]", GetExecutableName()); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return; } var inputPath = Path.GetFullPath(extras[0]); var outputPath = extras.Count > 1 ? extras[1] : Path.ChangeExtension(inputPath, null) + "_unpack"; var kft = new KnownFileTypes(); var kftPath = Path.Combine(GetExecutablePath(), "archive_file_types.cfg"); if (File.Exists(kftPath) == true) { kft.Load(kftPath); } using (var input = File.OpenRead(inputPath)) { var archive = new ArchiveFile(); archive.Deserialize(input); long current = 0; long total = archive.Entries.Count; var padding = total.ToString(CultureInfo.InvariantCulture).Length; foreach (var entry in archive.Entries) { current++; var entryName = entry.Name; if (kft.Contains(entry.TypeHash) == false) { entryName += ".UNK#" + entry.TypeHash.ToString("X8"); } else { entryName += kft.GetExtension(entry.TypeHash) ?? "." + kft.GetName(entry.TypeHash); } var entryPath = Path.Combine(outputPath, entryName); if (overwriteFiles == false && File.Exists(entryPath) == true) { continue; } if (verbose == true) { Console.WriteLine("[{0}/{1}] {2}", current.ToString(CultureInfo.InvariantCulture).PadLeft(padding), total, entryName); } input.Seek(entry.Offset, SeekOrigin.Begin); var entryDirectory = Path.GetDirectoryName(entryPath); if (entryDirectory != null) { Directory.CreateDirectory(entryDirectory); } using (var output = File.Create(entryPath)) { input.Seek(entry.Offset, SeekOrigin.Begin); if (archive.Version == 8) { if (entry.CompressedSize == entry.UncompressedSize) { output.WriteFromStream(input, entry.UncompressedSize); } else { using (var temp = input.ReadToMemoryStream(entry.CompressedSize)) { var zlib = new InflaterInputStream(temp); output.WriteFromStream(zlib, entry.UncompressedSize); } } } else if (archive.Version == 17) { if (entry.CompressedSize == entry.UncompressedSize) { output.WriteFromStream(input, entry.UncompressedSize); } else { var compressed = input.ReadBytes(entry.CompressedSize); var uncompressed = new byte[entry.UncompressedSize]; using (var context = new XCompression.DecompressionContext(0x8000)) { var compressedSize = compressed.Length; var uncompressedSize = uncompressed.Length; if ( context.Decompress(compressed, 0, ref compressedSize, uncompressed, 0, ref uncompressedSize) != XCompression.ErrorCode.None) { throw new InvalidOperationException(); } if (uncompressedSize != uncompressed.Length || compressedSize != compressed.Length) { throw new InvalidOperationException(); } output.WriteBytes(uncompressed); } } } else { throw new NotSupportedException(); } } } } }