@@ -117,16 +117,6 @@ void TryCreateDir(const std::filesystem::path& dir_name) {
117117 throw databento::Exception{" Unable to create directory " s +
118118 dir_name.generic_string () + " : " + ec.message ()};
119119}
120-
121- std::string PathJoin (const std::string& dir, const std::string& path) {
122- if (dir.empty ()) {
123- return path;
124- }
125- if (dir[dir.length () - 1 ] == ' /' ) {
126- return dir + path;
127- }
128- return dir + ' /' + path;
129- }
130120} // namespace
131121
132122Historical::Historical (ILogReceiver* log_receiver, std::string key,
@@ -285,25 +275,25 @@ std::vector<databento::BatchFileDesc> Historical::BatchListFiles(
285275 return files;
286276}
287277
288- std::vector<std::string > Historical::BatchDownload (
289- const std::string & output_dir, const std::string& job_id) {
278+ std::vector<std::filesystem::path > Historical::BatchDownload (
279+ const std::filesystem::path & output_dir, const std::string& job_id) {
290280 TryCreateDir (output_dir);
291- const std::string job_dir = PathJoin ( output_dir, job_id) ;
281+ const std::filesystem::path job_dir = output_dir / job_id;
292282 TryCreateDir (job_dir);
293283 const auto file_descs = BatchListFiles (job_id);
294- std::vector<std::string > paths;
284+ std::vector<std::filesystem::path > paths;
295285 for (const auto & file_desc : file_descs) {
296- std::string output_path = PathJoin ( job_dir, file_desc.filename ) ;
286+ std::filesystem::path output_path = job_dir / file_desc.filename ;
297287 DownloadFile (file_desc.https_url , output_path);
298288 paths.emplace_back (std::move (output_path));
299289 }
300290 return paths;
301291}
302- std::string Historical::BatchDownload (const std::string& output_dir,
303- const std::string& job_id,
304- const std::string& filename_to_download) {
292+ std::filesystem::path Historical::BatchDownload (
293+ const std::filesystem::path& output_dir, const std::string& job_id,
294+ const std::string& filename_to_download) {
305295 TryCreateDir (output_dir);
306- const std::string job_dir = PathJoin ( output_dir, job_id) ;
296+ const std::filesystem::path job_dir = output_dir / job_id;
307297 TryCreateDir (job_dir);
308298 const auto file_descs = BatchListFiles (job_id);
309299 const auto file_desc_it =
@@ -316,14 +306,14 @@ std::string Historical::BatchDownload(const std::string& output_dir,
316306 " filename_to_download" ,
317307 " Filename not found for batch job " + job_id};
318308 }
319- std::string output_path = PathJoin ( job_dir, file_desc_it->filename ) ;
309+ std::filesystem::path output_path = job_dir / file_desc_it->filename ;
320310 DownloadFile (file_desc_it->https_url , output_path);
321311 return output_path;
322312}
323313
324314void Historical::StreamToFile (const std::string& url_path,
325315 const HttplibParams& params,
326- const std::string & file_path) {
316+ const std::filesystem::path & file_path) {
327317 OutFileStream out_file{file_path};
328318 this ->client_ .GetRawStream (
329319 url_path, params, [&out_file](const char * data, std::size_t length) {
@@ -333,7 +323,7 @@ void Historical::StreamToFile(const std::string& url_path,
333323}
334324
335325void Historical::DownloadFile (const std::string& url,
336- const std::string & output_path) {
326+ const std::filesystem::path & output_path) {
337327 static const std::string kEndpoint = " Historical::DownloadFile" ;
338328 // extract path from URL
339329 const auto protocol_divider = url.find (" ://" );
@@ -870,7 +860,7 @@ static const std::string kTimeseriesGetRangeToFileEndpoint =
870860databento::DbnFileStore Historical::TimeseriesGetRangeToFile (
871861 const std::string& dataset, const DateTimeRange<UnixNanos>& datetime_range,
872862 const std::vector<std::string>& symbols, Schema schema,
873- const std::string & file_path) {
863+ const std::filesystem::path & file_path) {
874864 return this ->TimeseriesGetRangeToFile (dataset, datetime_range, symbols,
875865 schema, kDefaultSTypeIn ,
876866 kDefaultSTypeOut , {}, file_path);
@@ -879,15 +869,16 @@ databento::DbnFileStore Historical::TimeseriesGetRangeToFile(
879869 const std::string& dataset,
880870 const DateTimeRange<std::string>& datetime_range,
881871 const std::vector<std::string>& symbols, Schema schema,
882- const std::string & file_path) {
872+ const std::filesystem::path & file_path) {
883873 return this ->TimeseriesGetRangeToFile (dataset, datetime_range, symbols,
884874 schema, kDefaultSTypeIn ,
885875 kDefaultSTypeOut , {}, file_path);
886876}
887877databento::DbnFileStore Historical::TimeseriesGetRangeToFile (
888878 const std::string& dataset, const DateTimeRange<UnixNanos>& datetime_range,
889879 const std::vector<std::string>& symbols, Schema schema, SType stype_in,
890- SType stype_out, std::uint64_t limit, const std::string& file_path) {
880+ SType stype_out, std::uint64_t limit,
881+ const std::filesystem::path& file_path) {
891882 httplib::Params params{
892883 {" dataset" , dataset},
893884 {" encoding" , " dbn" },
@@ -906,7 +897,8 @@ databento::DbnFileStore Historical::TimeseriesGetRangeToFile(
906897 const std::string& dataset,
907898 const DateTimeRange<std::string>& datetime_range,
908899 const std::vector<std::string>& symbols, Schema schema, SType stype_in,
909- SType stype_out, std::uint64_t limit, const std::string& file_path) {
900+ SType stype_out, std::uint64_t limit,
901+ const std::filesystem::path& file_path) {
910902 httplib::Params params{
911903 {" dataset" , dataset},
912904 {" encoding" , " dbn" },
@@ -922,7 +914,7 @@ databento::DbnFileStore Historical::TimeseriesGetRangeToFile(
922914 return this ->TimeseriesGetRangeToFile (params, file_path);
923915}
924916databento::DbnFileStore Historical::TimeseriesGetRangeToFile (
925- const HttplibParams& params, const std::string & file_path) {
917+ const HttplibParams& params, const std::filesystem::path & file_path) {
926918 StreamToFile (kTimeseriesGetRangePath , params, file_path);
927919 return DbnFileStore{log_receiver_, file_path,
928920 VersionUpgradePolicy::UpgradeToV3};
0 commit comments