diff --git a/DotNetDBF.Test/DotNetDBF.Test.csproj b/DotNetDBF.Test/DotNetDBF.Test.csproj index 5121a7c..23cae51 100644 --- a/DotNetDBF.Test/DotNetDBF.Test.csproj +++ b/DotNetDBF.Test/DotNetDBF.Test.csproj @@ -43,10 +43,26 @@ + + + + + + + + + + + + + + + + @@ -59,5 +75,15 @@ DotNetDBF + + + + + + + + + + \ No newline at end of file diff --git a/DotNetDBF.Test/Issue19Test.cs b/DotNetDBF.Test/Issue19Test.cs new file mode 100644 index 0000000..0b28ea2 --- /dev/null +++ b/DotNetDBF.Test/Issue19Test.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace DotNetDBF.Test +{ + + [TestFixture] + public class Issue19Test + { + private Stream DbfsData(string filename) => typeof(Issue19Test).Assembly + .GetManifestResourceStream($"{nameof(DotNetDBF)}.{nameof(Test)}.dbfs.{filename}"); + + [Test] + public void ReadTest() + { + using (var dbfstream = DbfsData("dbase_8b.dbf")) + using (var memoStream = DbfsData("dbase_8b.dbt")) + using (DBFReader dbfr = new DBFReader(dbfstream) { DataMemo = memoStream}) + { + object[] record = dbfr.NextRecord(); + //This line would hang issue #19 https://github.com/ekonbenefits/dotnetdbf/issues/19 + Assert.Throws(() => record[5].ToString()); + } + } + } +} diff --git a/DotNetDBF.Test/dbfs/Readme.md b/DotNetDBF.Test/dbfs/Readme.md new file mode 100644 index 0000000..43ae652 --- /dev/null +++ b/DotNetDBF.Test/dbfs/Readme.md @@ -0,0 +1,22 @@ +Most of the DBFs here are from the spec directory of the dbf ruby gem + +Copyright (c) 2006-2017 Keith Morrison + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/DotNetDBF.Test/dbfs/cp1251.dbf b/DotNetDBF.Test/dbfs/cp1251.dbf new file mode 100644 index 0000000..eea8b4b Binary files /dev/null and b/DotNetDBF.Test/dbfs/cp1251.dbf differ diff --git a/DotNetDBF.Test/dbfs/cp1251_summary.txt b/DotNetDBF.Test/dbfs/cp1251_summary.txt new file mode 100644 index 0000000..924199c --- /dev/null +++ b/DotNetDBF.Test/dbfs/cp1251_summary.txt @@ -0,0 +1,11 @@ + +Database: cp1251.dbf +Type: (30) Visual FoxPro +Memo File: false +Records: 4 + +Fields: +Name Type Length Decimal +------------------------------------------------------------------------------ +RN N 4 0 +NAME C 100 0 diff --git a/DotNetDBF.Test/dbfs/dbase_03.dbf b/DotNetDBF.Test/dbfs/dbase_03.dbf new file mode 100644 index 0000000..b6ed141 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_03.dbf differ diff --git a/DotNetDBF.Test/dbfs/dbase_03_summary.txt b/DotNetDBF.Test/dbfs/dbase_03_summary.txt new file mode 100644 index 0000000..6172a5c --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_03_summary.txt @@ -0,0 +1,40 @@ + +Database: dbase_03.dbf +Type: (03) dBase III without memo file +Memo File: false +Records: 14 + +Fields: +Name Type Length Decimal +------------------------------------------------------------------------------ +Point_ID C 12 0 +Type C 20 0 +Shape C 20 0 +Circular_D C 20 0 +Non_circul C 60 0 +Flow_prese C 20 0 +Condition C 20 0 +Comments C 60 0 +Date_Visit D 8 0 +Time C 10 0 +Max_PDOP N 5 1 +Max_HDOP N 5 1 +Corr_Type C 36 0 +Rcvr_Type C 36 0 +GPS_Date D 8 0 +GPS_Time C 10 0 +Update_Sta C 36 0 +Feat_Name C 20 0 +Datafile C 20 0 +Unfilt_Pos N 10 0 +Filt_Pos N 10 0 +Data_Dicti C 20 0 +GPS_Week N 6 0 +GPS_Second N 12 3 +GPS_Height N 16 3 +Vert_Prec N 16 1 +Horz_Prec N 16 1 +Std_Dev N 16 6 +Northing N 16 3 +Easting N 16 3 +Point_ID N 9 0 diff --git a/DotNetDBF.Test/dbfs/dbase_30.dbf b/DotNetDBF.Test/dbfs/dbase_30.dbf new file mode 100644 index 0000000..1d10507 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_30.dbf differ diff --git a/DotNetDBF.Test/dbfs/dbase_30.fpt b/DotNetDBF.Test/dbfs/dbase_30.fpt new file mode 100644 index 0000000..64a5660 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_30.fpt differ diff --git a/DotNetDBF.Test/dbfs/dbase_30_summary.txt b/DotNetDBF.Test/dbfs/dbase_30_summary.txt new file mode 100644 index 0000000..a9fca0f --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_30_summary.txt @@ -0,0 +1,154 @@ + +Database: dbase_30.dbf +Type: (30) Visual FoxPro +Memo File: true +Records: 34 + +Fields: +Name Type Length Decimal +------------------------------------------------------------------------------ +ACCESSNO C 15 0 +ACQVALUE N 12 2 +APPNOTES M 4 0 +APPRAISOR C 75 0 +CABINET C 25 0 +CAPTION C 30 0 +CAT C 1 0 +CATBY C 25 0 +CATDATE D 8 0 +CATTYPE C 15 0 +CLASSES M 4 0 +COLLECTION C 75 0 +CONDDATE D 8 0 +CONDEXAM C 25 0 +CONDITION C 35 0 +CONDNOTES M 4 0 +CONTAINER C 40 0 +COPYRIGHT M 4 0 +CREATOR C 80 0 +CREDIT M 4 0 +CURVALMAX N 12 2 +CURVALUE N 12 2 +DATASET C 15 0 +DATE C 50 0 +DESCRIP M 4 0 +DIMNOTES M 4 0 +DISPVALUE C 10 0 +DRAWER C 20 0 +EARLYDATE N 4 0 +EVENT C 80 0 +EXHIBITID C 36 0 +EXHIBITNO N 7 0 +EXHLABEL1 M 4 0 +EXHLABEL2 M 4 0 +EXHLABEL3 M 4 0 +EXHLABEL4 M 4 0 +EXHSTART D 8 0 +FILMSIZE C 35 0 +FLAGDATE T 8 0 +FLAGNOTES M 4 0 +FLAGREASON C 20 0 +FRAME C 75 0 +FRAMENO C 25 0 +GPARENT C 45 0 +HOMELOC C 60 0 +IMAGEFILE C 60 0 +IMAGENO N 3 0 +INSCOMP C 30 0 +INSDATE D 8 0 +INSPHONE C 25 0 +INSPREMIUM C 20 0 +INSREP C 30 0 +INSVALUE N 10 2 +INVNBY C 25 0 +INVNDATE D 8 0 +LATEDATE N 4 0 +LEGAL M 4 0 +LOANCOND M 4 0 +LOANDATE D 8 0 +LOANDUE D 8 0 +LOANID C 36 0 +LOANINNO C 15 0 +MAINTCYCLE C 10 0 +MAINTDATE D 8 0 +MAINTNOTE M 4 0 +MEDIUM C 75 0 +NEGLOC C 60 0 +NEGNO C 25 0 +NOTES M 4 0 +OBJECTID C 25 0 +OBJNAME C 40 0 +OLDNO C 25 0 +ORIGCOPY C 15 0 +OTHERNO C 25 0 +OUTDATE D 8 0 +PARENT C 40 0 +PEOPLE M 4 0 +PLACE C 100 0 +POLICYNO C 20 0 +PRINTSIZE C 35 0 +PROCESS C 75 0 +PROVENANCE M 4 0 +PUBNOTES M 4 0 +RECAS C 20 0 +RECDATE C 10 0 +RECFROM C 120 0 +RELATION C 36 0 +RELNOTES M 4 0 +ROOM C 25 0 +SGFLAG C 1 0 +SHELF C 20 0 +SITE C 40 0 +SITENO C 12 0 +SLIDENO C 25 0 +STATUS C 20 0 +STATUSBY C 25 0 +STATUSDATE D 8 0 +STERMS M 4 0 +STUDIO C 60 0 +SUBJECTS M 4 0 +TCABINET C 25 0 +TCONTAINER C 40 0 +TDRAWER C 20 0 +TEMPAUTHOR C 25 0 +TEMPBY C 25 0 +TEMPDATE D 8 0 +TEMPLOC C 60 0 +TEMPNOTES M 4 0 +TEMPREASON C 50 0 +TEMPUNTIL C 10 0 +TITLE M 4 0 +TITLESORT C 100 0 +TROOM C 25 0 +TSHELF C 20 0 +TWALL C 20 0 +UDF1 C 75 0 +UDF10 C 75 0 +UDF11 C 20 0 +UDF12 C 20 0 +UDF13 N 12 0 +UDF14 N 12 2 +UDF15 N 12 2 +UDF16 N 12 3 +UDF17 N 12 3 +UDF18 D 8 0 +UDF19 D 8 0 +UDF20 D 8 0 +UDF21 M 4 0 +UDF22 M 4 0 +UDF2 C 75 0 +UDF3 C 75 0 +UDF4 C 75 0 +UDF5 C 75 0 +UDF6 C 75 0 +UDF7 C 75 0 +UDF8 C 75 0 +UDF9 C 75 0 +UPDATED T 8 0 +UPDATEDBY C 25 0 +VALUEDATE D 8 0 +WALL C 20 0 +WEBINCLUDE L 1 0 +ZSORTER C 69 0 +ZSORTERX C 44 0 +PPID C 36 0 diff --git a/DotNetDBF.Test/dbfs/dbase_31.dbf b/DotNetDBF.Test/dbfs/dbase_31.dbf new file mode 100644 index 0000000..057c46b Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_31.dbf differ diff --git a/DotNetDBF.Test/dbfs/dbase_31_summary.txt b/DotNetDBF.Test/dbfs/dbase_31_summary.txt new file mode 100644 index 0000000..35e98ae --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_31_summary.txt @@ -0,0 +1,20 @@ + +Database: dbase_31.dbf +Type: (31) Visual FoxPro with AutoIncrement field +Memo File: false +Records: 77 + +Fields: +Name Type Length Decimal +------------------------------------------------------------------------------ +PRODUCTID I 4 0 +PRODUCTNAM C 40 0 +SUPPLIERID I 4 0 +CATEGORYID I 4 0 +QUANTITYPE C 20 0 +UNITPRICE Y 8 4 +UNITSINSTO I 4 0 +UNITSONORD I 4 0 +REORDERLEV I 4 0 +DISCONTINU L 1 0 +_NullFlags 0 1 0 diff --git a/DotNetDBF.Test/dbfs/dbase_83.dbf b/DotNetDBF.Test/dbfs/dbase_83.dbf new file mode 100644 index 0000000..f374436 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_83.dbf differ diff --git a/DotNetDBF.Test/dbfs/dbase_83.dbt b/DotNetDBF.Test/dbfs/dbase_83.dbt new file mode 100644 index 0000000..6fc1457 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_83.dbt differ diff --git a/DotNetDBF.Test/dbfs/dbase_83_missing_memo.dbf b/DotNetDBF.Test/dbfs/dbase_83_missing_memo.dbf new file mode 100644 index 0000000..f374436 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_83_missing_memo.dbf differ diff --git a/DotNetDBF.Test/dbfs/dbase_83_missing_memo_record_0.yml b/DotNetDBF.Test/dbfs/dbase_83_missing_memo_record_0.yml new file mode 100644 index 0000000..27680cf --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_83_missing_memo_record_0.yml @@ -0,0 +1,16 @@ +--- +- 87 +- 2 +- 0 +- 0 +- 87 +- '1' +- Assorted Petits Fours +- graphics/00000001/t_1.jpg +- graphics/00000001/1.jpg +- 0.0 +- 0.0 +- +- 5.51 +- true +- true diff --git a/DotNetDBF.Test/dbfs/dbase_83_record_0.yml b/DotNetDBF.Test/dbfs/dbase_83_record_0.yml new file mode 100644 index 0000000..40d640f --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_83_record_0.yml @@ -0,0 +1,16 @@ +--- + - 87 + - 2 + - 0 + - 0 + - 87 + - '1' + - Assorted Petits Fours + - graphics/00000001/t_1.jpg + - graphics/00000001/1.jpg + - 0.0 + - 0.0 + - "Our Original assortment...a little taste of heaven for everyone. Let us\r\nselect a special assortment of our chocolate and pastel favorites for you.\r\nEach petit four is its own special hand decorated creation. Multi-layers of\r\nmoist cake with combinations of specialty fillings create memorable cake\r\nconfections. Varietes include; Luscious Lemon, Strawberry Hearts, White\r\nChocolate, Mocha Bean, Roasted Almond, Triple Chocolate, Chocolate Hazelnut,\r\nGrand Orange, Plum Squares, Milk chocolate squares, and Raspberry Blanc." + - 5.51 + - true + - true diff --git a/DotNetDBF.Test/dbfs/dbase_83_record_9.yml b/DotNetDBF.Test/dbfs/dbase_83_record_9.yml new file mode 100644 index 0000000..32fd752 --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_83_record_9.yml @@ -0,0 +1,23 @@ +--- +- 34 +- 1 +- 0 +- 0 +- 34 +- AB01 +- Apricot Brandy Fruitcake +- graphics/00000001/t_AB01.jpg +- graphics/00000001/AB01.jpg +- 37.95 +- 37.95 +- "Once tasted you will understand why we won The\r\nBoston Herald's Fruitcake Taste-off. + Judges liked its generous size,\r\nluscious appearance, moist texture and fruit + to cake ratio ... commented one\r\njudge \"It's a lip Smacker!\" Our signature fruitcake + is baked with carefully\r\nselected ingredients that will be savored until the last + moist crumb is\r\ndevoured each golden slice is brimming with Australian glaced + apricots,\r\ntoasted pecans, candied orange peel, and currants, folded gently into + a\r\nbrandy butter batter and slowly baked to perfection and then generously\r\nimbibed + with \"Holiday Spirits\". Presented in a gift tin. (3lbs. 4oz)" +- 0.0 +- false +- true diff --git a/DotNetDBF.Test/dbfs/dbase_83_schema.txt b/DotNetDBF.Test/dbfs/dbase_83_schema.txt new file mode 100644 index 0000000..803db88 --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_83_schema.txt @@ -0,0 +1,19 @@ +ActiveRecord::Schema.define do + create_table "dbase_83" do |t| + t.column "id", :integer + t.column "catcount", :integer + t.column "agrpcount", :integer + t.column "pgrpcount", :integer + t.column "order", :integer + t.column "code", :string, :limit => 50 + t.column "name", :string, :limit => 100 + t.column "thumbnail", :string, :limit => 254 + t.column "image", :string, :limit => 254 + t.column "price", :float + t.column "cost", :float + t.column "desc", :text + t.column "weight", :float + t.column "taxable", :boolean + t.column "active", :boolean + end +end \ No newline at end of file diff --git a/DotNetDBF.Test/dbfs/dbase_83_summary.txt b/DotNetDBF.Test/dbfs/dbase_83_summary.txt new file mode 100644 index 0000000..24a3483 --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_83_summary.txt @@ -0,0 +1,24 @@ + +Database: dbase_83.dbf +Type: (83) dBase III with memo file +Memo File: true +Records: 67 + +Fields: +Name Type Length Decimal +------------------------------------------------------------------------------ +ID N 19 0 +CATCOUNT N 19 0 +AGRPCOUNT N 19 0 +PGRPCOUNT N 19 0 +ORDER N 19 0 +CODE C 50 0 +NAME C 100 0 +THUMBNAIL C 254 0 +IMAGE C 254 0 +PRICE N 13 2 +COST N 13 2 +DESC M 10 0 +WEIGHT N 13 2 +TAXABLE L 1 0 +ACTIVE L 1 0 diff --git a/DotNetDBF.Test/dbfs/dbase_8b.dbf b/DotNetDBF.Test/dbfs/dbase_8b.dbf new file mode 100644 index 0000000..9e0ec13 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_8b.dbf differ diff --git a/DotNetDBF.Test/dbfs/dbase_8b.dbt b/DotNetDBF.Test/dbfs/dbase_8b.dbt new file mode 100644 index 0000000..527663a Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_8b.dbt differ diff --git a/DotNetDBF.Test/dbfs/dbase_8b_summary.txt b/DotNetDBF.Test/dbfs/dbase_8b_summary.txt new file mode 100644 index 0000000..7be9219 --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_8b_summary.txt @@ -0,0 +1,15 @@ + +Database: dbase_8b.dbf +Type: (8b) dBase IV with memo file +Memo File: true +Records: 10 + +Fields: +Name Type Length Decimal +------------------------------------------------------------------------------ +CHARACTER C 100 0 +NUMERICAL N 20 2 +DATE D 8 0 +LOGICAL L 1 0 +FLOAT F 20 18 +MEMO M 10 0 diff --git a/DotNetDBF.Test/dbfs/dbase_f5.dbf b/DotNetDBF.Test/dbfs/dbase_f5.dbf new file mode 100644 index 0000000..ed95dfa Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_f5.dbf differ diff --git a/DotNetDBF.Test/dbfs/dbase_f5.fpt b/DotNetDBF.Test/dbfs/dbase_f5.fpt new file mode 100644 index 0000000..bafff00 Binary files /dev/null and b/DotNetDBF.Test/dbfs/dbase_f5.fpt differ diff --git a/DotNetDBF.Test/dbfs/dbase_f5_summary.txt b/DotNetDBF.Test/dbfs/dbase_f5_summary.txt new file mode 100644 index 0000000..6506b37 --- /dev/null +++ b/DotNetDBF.Test/dbfs/dbase_f5_summary.txt @@ -0,0 +1,68 @@ + +Database: dbase_f5.dbf +Type: (f5) FoxPro with memo file +Memo File: true +Records: 975 + +Fields: +Name Type Length Decimal +------------------------------------------------------------------------------ +NF N 5 0 +SEXE C 1 0 +NOM C 20 0 +COG1 C 15 0 +COG2 C 15 0 +TELEFON C 9 0 +RENOM C 15 0 +NFP N 5 0 +NFM N 5 0 +ARXN C 10 0 +DATN D 8 0 +LLON C 15 0 +MUNN C 15 0 +COMN C 15 0 +PROV C 15 0 +PAIN C 15 0 +OFIC C 15 0 +ARXB C 10 0 +DATB D 8 0 +LLOB C 15 0 +MUNB C 15 0 +COMB C 15 0 +PAIB C 15 0 +DRIB C 30 0 +INAB C 30 0 +OFTB C 10 0 +OFNB C 20 0 +AXC1 C 10 0 +DTC1 D 8 0 +LLC1 C 15 0 +NFC1 N 5 0 +TCA1 C 10 0 +OTC1 C 10 0 +ONC1 C 20 0 +AXC2 C 10 0 +DTC2 D 8 0 +LLC2 C 15 0 +NFC2 N 5 0 +TCA2 C 10 0 +OTC2 C 10 0 +ONC2 C 20 0 +AXC3 C 10 0 +DTC3 D 8 0 +LLC3 C 15 0 +NFC3 N 5 0 +TCA3 C 10 0 +OTC3 C 10 0 +ONC3 C 20 0 +ARXD C 10 0 +DATD D 8 0 +LLOD C 15 0 +OFTD C 10 0 +OFND C 20 0 +OBS1 C 70 0 +OBS2 C 70 0 +OBS3 C 70 0 +OBS4 C 70 0 +OBSE M 10 0 +GHD C 15 0 diff --git a/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DBC b/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DBC new file mode 100644 index 0000000..d1d1c07 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DBC differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DCT b/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DCT new file mode 100644 index 0000000..4405062 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DCT differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DCX b/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DCX new file mode 100644 index 0000000..d962cef Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/FOXPRO-DB-TEST.DCX differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/calls.CDX b/DotNetDBF.Test/dbfs/foxprodb/calls.CDX new file mode 100644 index 0000000..1542679 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/calls.CDX differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/calls.FPT b/DotNetDBF.Test/dbfs/foxprodb/calls.FPT new file mode 100644 index 0000000..30957b0 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/calls.FPT differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/calls.dbf b/DotNetDBF.Test/dbfs/foxprodb/calls.dbf new file mode 100644 index 0000000..4096747 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/calls.dbf differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/contacts.CDX b/DotNetDBF.Test/dbfs/foxprodb/contacts.CDX new file mode 100644 index 0000000..d0722b0 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/contacts.CDX differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/contacts.FPT b/DotNetDBF.Test/dbfs/foxprodb/contacts.FPT new file mode 100644 index 0000000..31b3dfa Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/contacts.FPT differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/contacts.dbf b/DotNetDBF.Test/dbfs/foxprodb/contacts.dbf new file mode 100644 index 0000000..d990efb Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/contacts.dbf differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/setup.CDX b/DotNetDBF.Test/dbfs/foxprodb/setup.CDX new file mode 100644 index 0000000..92787a1 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/setup.CDX differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/setup.dbf b/DotNetDBF.Test/dbfs/foxprodb/setup.dbf new file mode 100644 index 0000000..e214c3d Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/setup.dbf differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/types.CDX b/DotNetDBF.Test/dbfs/foxprodb/types.CDX new file mode 100644 index 0000000..a346202 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/types.CDX differ diff --git a/DotNetDBF.Test/dbfs/foxprodb/types.dbf b/DotNetDBF.Test/dbfs/foxprodb/types.dbf new file mode 100644 index 0000000..ebb3bc6 Binary files /dev/null and b/DotNetDBF.Test/dbfs/foxprodb/types.dbf differ diff --git a/DotNetDBF/DBFException.cs b/DotNetDBF/DBFException.cs index db96bf6..426ed3c 100644 --- a/DotNetDBF/DBFException.cs +++ b/DotNetDBF/DBFException.cs @@ -16,6 +16,34 @@ original author (javadbf): anil@linuxense.com 2004/03/31 namespace DotNetDBF { + public class DBTException : DBFException + { + + public DBTException(String msg) : base(msg) + { + } + + public DBTException(String msg, Exception internalException) + : base(msg, internalException) + { + } + } + + public class DBFRecordException : DBFException + { + public int Record { get; } + + public DBFRecordException(String msg, int record) : base(msg) + { + Record = record; + } + + public DBFRecordException(String msg, Exception internalException) + : base(msg, internalException) + { + } + } + public class DBFException : IOException { public DBFException() : base() diff --git a/DotNetDBF/DBFWriter.cs b/DotNetDBF/DBFWriter.cs index 58f9519..a892d66 100644 --- a/DotNetDBF/DBFWriter.cs +++ b/DotNetDBF/DBFWriter.cs @@ -260,47 +260,41 @@ private void AddRecord(Object[] values, bool writeImediately) case NativeDbType.Char: if (!(values[i] is String) && !(values[i] is DBNull)) { - throw new DBFException("Invalid value for field " - + i); + throw new DBFRecordException($"Invalid value for field {i}", i); } break; case NativeDbType.Logical: if (!(values[i] is Boolean) && !(values[i] is DBNull)) { - throw new DBFException("Invalid value for field " - + i); + throw new DBFRecordException($"Invalid value for field {i}", i); } break; case NativeDbType.Numeric: if (!(values[i] is IConvertible) && !(values[i] is DBNull)) { - throw new DBFException("Invalid value for field " - + i); + throw new DBFRecordException($"Invalid value for field {i}", i); } break; case NativeDbType.Date: if (!(values[i] is DateTime) && !(values[i] is DBNull)) { - throw new DBFException("Invalid value for field " - + i); + throw new DBFRecordException($"Invalid value for field {i}", i); } break; case NativeDbType.Float: if (!(values[i] is IConvertible) && !(values[i] is DBNull)) { - throw new DBFException("Invalid value for field " - + i); + throw new DBFRecordException($"Invalid value for field {i}", i); } break; case NativeDbType.Memo: if (!(values[i] is MemoValue) && !(values[i] is DBNull)) { - throw new DBFException("Invalid value for field " - + i); + throw new DBFRecordException($"Invalid value for field {i}", i); } break; } diff --git a/DotNetDBF/DotNetDBF.csproj b/DotNetDBF/DotNetDBF.csproj index 9b7e888..acb3ddd 100644 --- a/DotNetDBF/DotNetDBF.csproj +++ b/DotNetDBF/DotNetDBF.csproj @@ -3,9 +3,9 @@ net35;netstandard1.3 True sn.snk - 5.0.2.0 - 5.0.2.0 - 5.0.2.0 + 5.0.3.0 + 5.0.3.0 + 5.0.3.0 Ekon Benefits Copyright 2009-2017 This is a basic file parser for reading and writing xBase DBF files particularlly Clipper. Code originally derived from javadbf. diff --git a/DotNetDBF/MemoValue.cs b/DotNetDBF/MemoValue.cs index 41e4ef9..26d289d 100644 --- a/DotNetDBF/MemoValue.cs +++ b/DotNetDBF/MemoValue.cs @@ -111,10 +111,14 @@ public string Value int tIndex; var tSoftReturn = _base.CharEncoding.GetString(new byte[] {0x8d, 0x0a}); + byte[] tData; do { - var tData = reader.ReadBytes(_base.BlockSize); - + tData = reader.ReadBytes(_base.BlockSize); + if ((tData.Length == 0)) + { + throw new DBTException("Missing Data for block or no 1a memo terminiator"); + } var tString = _base.CharEncoding.GetString(tData); tIndex = tString.IndexOf(MemoTerminator, StringComparison.Ordinal); if (tIndex != -1)