static void Main(string[] args) { string fpath = args[0]; var fr = new FileRead(); fr.ReadGed(fpath); string opath = Path.ChangeExtension(fpath, "ged_out"); FileWrite.WriteGED(fr.Data, opath); //string apath = @"E:\TestGeds"; //string apath = @"Z:\HOST_E\projects\GED\GED files\Ged too big\2524482.ged"; //Console.WriteLine(apath); //dump(fr.Data); //var files = Directory.GetFiles(apath, "*.ged"); //foreach (var afile in files) //{ // Console.WriteLine(afile); // var fr = new FileRead(); // fr.ReadGed(afile); // dump(fr.Data); //} }
public List <GEDCommon> CommonBasic(string txt, Encoding fileEnc) { // Exercise a file encoding var tmppath = Path.GetTempFileName(); FileStream fStream = null; try { fStream = new FileStream(tmppath, FileMode.Create); // Code analysis claims fStream will be disposed twice if 'using' using (StreamWriter stream = new StreamWriter(fStream, fileEnc)) { stream.Write(txt); } } finally { if (fStream != null) { fStream.Dispose(); } } FileRead fr = new FileRead(); fr.ReadGed(tmppath); File.Delete(tmppath); return(fr.Data.Select(o => o as GEDCommon).ToList()); }
public void DoFile(string path) { FileRead fr = new FileRead(); fr.ReadGed(path); var results = fr.Data; int indi = 0; int fam = 0; foreach (var result in results) { if ((result as IndiRecord) != null) { indi++; } if ((result as FamRecord) != null) { fam++; } } Assert.AreNotEqual(0, indi, path); Assert.AreNotEqual(0, fam, path); }
// For those tests which need to verify errors at the topmost level public static FileRead ReadItHigher(string testString) { // TODO as implemented, trailing newline in original string will cause an "empty line" error record to be generated FileRead fr = new FileRead(); using (var stream = new StreamReader(ToStream(testString))) { fr.ReadGed(null, stream); } return(fr); }
public void LoadFromStream(StreamReader stream) { _issues = new List <Issue>(); _gedReader = new FileRead(); _gedReader.ReadGed(null, stream); if (_gedReader.Data.Count < 1) // nothing to do! { return; } BuildTree(); CalcTrees(); }
public FileRead ReadFile(string contents, bool bom = false) { string path = MakeFile(contents, bom); FileRead fr = new FileRead(); fr.ReadGed(path); try { File.Delete(path); } catch (Exception) { } return(fr); }
public void BlankFiles() { // A set of 'blank' files (no data, BOM/no-BOM, does not start with "0 HEAD") FileRead fr = new FileRead(); var path = @"Z:\HOST_E\proj\GED\all_ged\09"; foreach (var file in Directory.GetFiles(path, "blank*.ged")) { fr.ReadGed(file); Assert.AreEqual(1, fr.Errors.Count); Assert.AreEqual(UnkRec.ErrorCode.EmptyFile, fr.Errors[0].Error, file); Assert.IsNotNull(fr.Data); Assert.AreEqual(0, fr.Data.Count); } }
public void BlankFiles() { // A set of 'blank' files (no data, BOM/no-BOM, does not start with "0 HEAD") FileRead fr = new FileRead(); var path = Path.Combine( TestContext.CurrentContext.TestDirectory, @"..\..\..\..\", @"Sample GED\blank"); foreach (var file in Directory.GetFiles(path, "blank*.ged")) { fr.ReadGed(file); Assert.AreEqual(1, fr.Errors.Count); Assert.AreEqual(UnkRec.ErrorCode.EmptyFile, fr.Errors[0].Error, file); Assert.IsNotNull(fr.Data); Assert.AreEqual(0, fr.Data.Count); } }
public void TestBasic() { // The smallest valid GED var txt = "0 HEAD\n1 SOUR 0\n1 SUBM @U_A@\n1 GEDC\n2 VERS 5.5.1\n2 FORM LINEAGE-LINKED\n1 CHAR ASCII\n0 @U_A@ SUBM\n1 NAME X\n0 TRLR"; var tmppath = Path.GetTempFileName(); using (StreamWriter stream = new StreamWriter(tmppath)) { stream.Write(txt); } FileRead fr = new FileRead(); fr.ReadGed(tmppath); var results = fr.Data; File.Delete(tmppath); Assert.AreEqual(2, results.Count); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Specify a GED file."); return; } string path = args[0]; if (!File.Exists(path)) { Console.WriteLine("File doesn't exist"); return; } // TODO exercise invalid .GED file var fr = new FileRead(); fr.ReadGed(args[0]); BuildTree(fr.Data); }
public static void ReadFile(string filename) { _reader = new FileRead(); // TODO needs to be reset for each file _reader.ReadGed(filename); }
private static void parseFile(string path, bool showErrors) { long beforeMem = GC.GetTotalMemory(true); if (_bsize == 0) { logit("", true); } if (!_csv) { Console.WriteLine(" {0}", Path.GetFileName(path)); } Console.Out.Flush(); if (_noforest) { using (FileRead reader = new FileRead(_bsize)) { reader.ReadGed(path); long afterMem = GC.GetTotalMemory(false); int ms = 0; if (_bsize == 0) { ms = logit("__load complete (ms)"); } long delta = (afterMem - beforeMem); double meg = delta / (1024 * 1024.0); if (_showDiags) { Console.WriteLine("\t===Memory:{0:0.00}M", meg); long maxMem = Process.GetCurrentProcess().PeakWorkingSet64; double maxM = maxMem / (1024 * 1024.0); Console.WriteLine("\t===MaxWSet:{0:0.00}M", maxM); } dump(reader.Data, reader.AllErrors, null, false); } } else { using (Forest f = new Forest()) { f.LoadGEDCOM(path, _bsize); var fil = File.OpenRead(path); long flen = fil.Length; fil.Close(); double fkb = flen / (1024.0); long afterMem = GC.GetTotalMemory(false); int ms = 0; if (_bsize == 0) { ms = logit("__load complete (ms)"); } long delta = (afterMem - beforeMem); double meg = delta / (1024 * 1024.0); if (_showDiags) { Console.WriteLine("\t===Memory:{0:0.00}M", meg); long maxMem = Process.GetCurrentProcess().PeakWorkingSet64; double maxM = maxMem / (1024 * 1024.0); Console.WriteLine("\t===MaxWSet:{0:0.00}M", maxM); } if (_dates) { dumpDates(f); } else if (_ged) { dump(f.AllRecords, f.Errors, f.Issues, showErrors); } else if (_csv) { dumpCSV(Path.GetFileNameWithoutExtension(path), f, ms, meg, fkb); } else { dump(f, showErrors); } if (_dumpAllErrors) { dumpAllErrors(null, f); } } } Console.Out.Flush(); }
/// <summary> /// Only parse a GEDCOM file. Useful for syntax validation. /// </summary> /// <param name="path"></param> /// <param name="bufferSize"></param> public void ParseGEDCOM(string path, int bufferSize = 0) { _gedReader = new FileRead(bufferSize); _gedReader.ReadGed(path); }