| 1 |
#include "getmode.h" |
| 2 |
|
| 3 |
unsigned short getmode__(const char* mode_str, unsigned short mode); |
| 4 |
|
| 5 |
std::string strmode__(unsigned short mode); |
| 6 |
|
| 7 |
std::string file_code__(const std::string& path, unsigned short mode); |
| 8 |
|
| 9 |
extern "C" SEXP fs_getmode_(SEXP mode_str_sxp, SEXP mode_sxp) { |
| 10 |
const char* mode_str = CHAR(STRING_ELT(mode_str_sxp, 0)); |
| 11 |
unsigned short mode = INTEGER(mode_sxp)[0]; |
| 12 |
unsigned short res = getmode__(mode_str, mode); |
| 13 |
|
| 14 |
return Rf_ScalarInteger(res); |
| 15 |
} |
| 16 |
|
| 17 |
extern "C" SEXP fs_strmode_(SEXP mode_sxp) { |
| 18 |
unsigned short mode = INTEGER(mode_sxp)[0]; |
| 19 |
SEXP out; |
| 20 |
|
| 21 |
BEGIN_CPP |
| 22 |
|
| 23 |
std::string res = strmode__(mode); |
| 24 |
out = Rf_mkString(res.c_str()); |
| 25 |
|
| 26 |
END_CPP |
| 27 |
|
| 28 |
return out; |
| 29 |
} |
| 30 |
|
| 31 |
extern "C" SEXP fs_file_code_(SEXP path_sxp, SEXP mode_sxp) { |
| 32 |
|
| 33 |
SEXP out; |
| 34 |
|
| 35 |
BEGIN_CPP |
| 36 |
|
| 37 |
std::string path(CHAR(STRING_ELT(path_sxp, 0))); |
| 38 |
unsigned short mode = INTEGER(mode_sxp)[0]; |
| 39 |
|
| 40 |
std::string res = file_code__(path, mode); |
| 41 |
|
| 42 |
out = Rf_mkString(res.c_str()); |
| 43 |
|
| 44 |
END_CPP |
| 45 |
|
| 46 |
return out; |
| 47 |
} |