diff --git a/src/unicode_fopen.h b/src/unicode_fopen.h index 049dbd20..292de57b 100644 --- a/src/unicode_fopen.h +++ b/src/unicode_fopen.h @@ -20,6 +20,17 @@ #include "cpp11/r_string.hpp" #endif +inline void print_hex(const char* string) { + unsigned char* p = (unsigned char*) string; + for (int i = 0; i < 300 ; i++) { + if (p[i] == '\0') break; + Rprintf("%c 0x%02x ", p[i], p[i]); + if ((i%16 == 0) && i) + Rprintf("\n"); + } + Rprintf("\n"); +} + // This is needed to support wide character paths on windows inline FILE* unicode_fopen(const char* path, const char* mode) { FILE* out; @@ -45,7 +56,11 @@ inline FILE* unicode_fopen(const char* path, const char* mode) { #else // cpp11 will have converted the user's path to UTF-8 by now // but we need to pass the path to fopen() in the native encoding + Rprintf("unicode_fopen() received path: %s\n", path); + print_hex(path); const char* native_path = Rf_translateChar(cpp11::r_string(path)); + Rprintf("Calling fopen() on native path: %s\n", native_path); + print_hex(native_path); out = fopen(native_path, mode); #endif @@ -72,7 +87,11 @@ make_mmap_source(const char* file, std::error_code& error) { #else // cpp11 will have converted the user's path to UTF-8 by now // but we need to pass the path to mio in the native encoding + Rprintf("make_mmap_source() received path: %s\n", file); + print_hex(file); const char* native_path = Rf_translateChar(cpp11::r_string(file)); + Rprintf("Calling mio::make_mmap_source() on native path: %s\n", native_path); + print_hex(native_path); return mio::make_mmap_source(native_path, error); #endif } diff --git a/src/vroom.cc b/src/vroom.cc index 6fe129c6..08f30780 100644 --- a/src/vroom.cc +++ b/src/vroom.cc @@ -95,9 +95,12 @@ [[cpp11::register]] bool has_trailing_newline(const cpp11::strings& filename) { std::FILE* f = unicode_fopen(CHAR(filename[0]), "rb"); + Rprintf("In has_trailing_newline(): "); if (!f) { + Rprintf("no file\n"); return true; } + Rprintf("yes file\n"); std::setvbuf(f, nullptr, _IONBF, 0);