@@ -105,6 +105,7 @@ int INIToCoreReader::valueHandler(void *user, const char *section,
105
105
Rcpp::Function normalizePath = base[" normalizePath" ];
106
106
Rcpp::Function dirname = base[" dirname" ];
107
107
Rcpp::Function filepath = base[" file.path" ];
108
+ Rcpp::Function fileexists = base[" file.exists" ];
108
109
#endif
109
110
110
111
static const string csvFilePrefix = " csv:" ;
@@ -144,20 +145,11 @@ int INIToCoreReader::valueHandler(void *user, const char *section,
144
145
// If the csvFileName normalizes to a real path, use that.
145
146
// Otherwise, assume that it is pointing to a file in the
146
147
// same directory as the INI file.
147
- try {
148
- // Second argument is "winslash", which is only used
149
- // on Windows machines and is ignored for Unix-based
150
- // systems. "\\" (single backward slash) is the
151
- // default. Need it here to access the third argument
152
- // -- mustWork -- which throws the error to be caught
153
- // if the path doesn't exist
154
- csvFileName = Rcpp::as<string>(normalizePath (csvFileName, " \\ " , true ));
155
- } catch (...) {
156
- // Get the full path of the INI file with
157
- // normalizePath. Then, get just the directory using dirname.
158
- Rcpp::String parentPath = dirname (normalizePath (reader->iniFilePath ));
159
- csvFileName = Rcpp::as<string>(filepath (parentPath, csvFileName));
160
- }
148
+ // csvFileName = Rcpp::as<string>(filepath(csvFileName));
149
+ if (!Rcpp::as<bool >(fileexists (csvFileName))) {
150
+ Rcpp::String parentPath = dirname (normalizePath (reader->iniFilePath ));
151
+ csvFileName = Rcpp::as<string>(filepath (parentPath, csvFileName));
152
+ }
161
153
#else
162
154
// ANS:: Algorithm for standalone Hector. Same logic -- if
163
155
// the given path (absolute or relative) points to a file
0 commit comments