The R Project SVN R-packages

Rev

Rev 665 | Rev 5040 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 665 Rev 957
Line 10... Line 10...
10
#include <stdlib.h>
10
#include <stdlib.h>
11
#include <string.h>
11
#include <string.h>
12
#include "shapefil.h"
12
#include "shapefil.h"
13
#include <R.h>
13
#include <R.h>
14
#include <Rinternals.h>
14
#include <Rinternals.h>
-
 
15
#include "foreign.h"
15
 
16
 
16
 
17
 
17
static DBFHandle Rdbfwrite(DBFHandle, SEXP, SEXP, SEXP, SEXP);
18
static DBFHandle Rdbfwrite(DBFHandle, SEXP, SEXP, SEXP, SEXP);
18
 
19
 
19
static char* nameMangleOut(char *dbfFldname, int len)
20
static char* nameMangleOut(char *dbfFldname, int len)
Line 28... Line 29...
28
SEXP DoWritedbf(SEXP file, SEXP df, SEXP pr, SEXP sc, SEXP DataTypes)
29
SEXP DoWritedbf(SEXP file, SEXP df, SEXP pr, SEXP sc, SEXP DataTypes)
29
{ 
30
{ 
30
    DBFHandle hDBF;
31
    DBFHandle hDBF;
31
 
32
 
32
    if (!isValidString(file))
33
    if (!isValidString(file))
33
	error ("first argument must be a file name\n");
34
	error (_("first argument must be a file name"));
34
 
35
 
35
    hDBF = DBFCreate(R_ExpandFileName(CHAR(STRING_ELT(file, 0))));
36
    hDBF = DBFCreate(R_ExpandFileName(CHAR(STRING_ELT(file, 0))));
36
    if (hDBF == NULL) error("unable to open file");
37
    if (hDBF == NULL) error(_("unable to open file"));
37
 
38
 
38
    Rdbfwrite(hDBF, df, pr, sc, DataTypes);
39
    Rdbfwrite(hDBF, df, pr, sc, DataTypes);
39
    DBFClose(hDBF); 
40
    DBFClose(hDBF); 
40
    return R_NilValue;
41
    return R_NilValue;
41
}
42
}
Line 75... Line 76...
75
	    break;
76
	    break;
76
        case 'D':
77
        case 'D':
77
	    DBFAddField(hDBF, nameMangleOut(szTitle,11), FTDate, 8, 0);
78
	    DBFAddField(hDBF, nameMangleOut(szTitle,11), FTDate, 8, 0);
78
	    break;
79
	    break;
79
	default:
80
	default:
80
	    error("Unknown data type");
81
	    error(_("unknown data type"));
81
	    break;
82
	    break;
82
	}
83
	}
83
    }
84
    }
84
 
85
 
85
    for(iRecord = 0; iRecord < nrecs; iRecord++) {
86
    for(iRecord = 0; iRecord < nrecs; iRecord++) {
Line 113... Line 114...
113
		    DBFWriteNULLAttribute(hDBF, iRecord, i);
114
		    DBFWriteNULLAttribute(hDBF, iRecord, i);
114
		else
115
		else
115
		    DBFWriteStringAttribute(hDBF, iRecord, i, CHAR(this));
116
		    DBFWriteStringAttribute(hDBF, iRecord, i, CHAR(this));
116
		break;
117
		break;
117
	    default:
118
	    default:
118
		error("Unknown data type");
119
		error(_("unknown data type"));
119
		break;
120
		break;
120
	    }
121
	    }
121
	} 
122
	} 
122
    }
123
    }
123
 
124