From 227528e64fbfc95f7f434cf12aea2983abd82564 Mon Sep 17 00:00:00 2001 From: Sebastian Hoehna Date: Mon, 16 Apr 2018 00:32:44 -0300 Subject: [PATCH] Small edit to source function to use full path including current working directory --- src/core/utils/RbFileManager.cpp | 2 +- src/revlanguage/functions/io/Func_source.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/utils/RbFileManager.cpp b/src/core/utils/RbFileManager.cpp index 60738683d..432a0d4b5 100644 --- a/src/core/utils/RbFileManager.cpp +++ b/src/core/utils/RbFileManager.cpp @@ -626,7 +626,7 @@ bool RbFileManager::openFile(std::ifstream& strm) // concatenate path and file name std::string file_pathName = file_path + path_separator + file_name; - + // here we assume that the presence of the path/file has // been checked elsewhere strm.open( file_pathName.c_str(), std::ios::in ); diff --git a/src/revlanguage/functions/io/Func_source.cpp b/src/revlanguage/functions/io/Func_source.cpp index a859ba7f2..5cd2f0f7e 100644 --- a/src/revlanguage/functions/io/Func_source.cpp +++ b/src/revlanguage/functions/io/Func_source.cpp @@ -41,8 +41,12 @@ RevPtr Func_source::execute( void ) /* Open file */ std::string fname = static_cast( args[0].getVariable()->getRevObject() ).getValue(); - std::ifstream inFile( fname.c_str() ); - + + RevBayesCore::RbFileManager reader = RevBayesCore::RbFileManager(fname); + std::ifstream inFile; + + // now open the stream + reader.openFile(inFile); bool echo_on = static_cast( args[1].getVariable()->getRevObject() ).getValue(); @@ -63,7 +67,6 @@ RevPtr Func_source::execute( void ) // Read a line std::string line; - RevBayesCore::RbFileManager reader = RevBayesCore::RbFileManager(); reader.safeGetline(inFile, line); lineNumber++;