Skip to content

Commit 0b26c2f

Browse files
committed
DEL: Dirent removal
1 parent 8959c66 commit 0b26c2f

File tree

3 files changed

+13
-39
lines changed

3 files changed

+13
-39
lines changed

CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14)
44
# Project details
55
#
66

7-
project("databento" VERSION 0.32.1 LANGUAGES CXX)
7+
project("databento" VERSION 0.33.0 LANGUAGES CXX)
88
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)
99

1010
#
@@ -225,18 +225,6 @@ else()
225225
add_system_include_property(date)
226226
endif()
227227

228-
#
229-
# Platform-specific dependencies
230-
#
231-
if(WIN32)
232-
find_path(
233-
DIRENT_INCLUDE_DIR "dirent.h"
234-
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include"
235-
REQUIRED
236-
)
237-
target_include_directories(${PROJECT_NAME} PRIVATE ${DIRENT_INCLUDE_DIR})
238-
endif()
239-
240228
target_link_libraries(
241229
${PROJECT_NAME}
242230
PUBLIC

src/historical.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "databento/historical.hpp"
22

3-
#include <dirent.h> // closedir, opendir
43
#include <httplib.h>
54
#include <nlohmann/json.hpp>
65

@@ -9,16 +8,12 @@
98
#include <cstddef> // size_t
109
#include <cstdlib> // get_env
1110
#include <exception> // exception, exception_ptr
12-
#include <iterator> // back_inserter
13-
#include <memory> // unique_ptr
11+
#include <filesystem>
12+
#include <iterator> // back_inserter
1413
#include <string>
14+
#include <system_error>
1515
#include <utility> // move
1616

17-
#include "databento/file_stream.hpp"
18-
#ifdef _WIN32
19-
#include <direct.h> // _mkdir
20-
#endif
21-
2217
#include "databento/constants.hpp"
2318
#include "databento/datetime.hpp"
2419
#include "databento/dbn_decoder.hpp"
@@ -28,6 +23,7 @@
2823
#include "databento/detail/shared_channel.hpp"
2924
#include "databento/enums.hpp"
3025
#include "databento/exceptions.hpp" // Exception, JsonResponseError
26+
#include "databento/file_stream.hpp"
3127
#include "databento/log.hpp"
3228
#include "databento/metadata.hpp"
3329
#include "databento/timeseries.hpp"
@@ -112,24 +108,18 @@ databento::BatchJob Parse(const std::string& endpoint,
112108
return res;
113109
}
114110

115-
void TryCreateDir(const std::string& dir_name) {
111+
void TryCreateDir(const std::filesystem::path& dir_name) {
112+
using namespace std::string_literals;
116113
if (dir_name.empty()) {
117114
return;
118115
}
119-
const std::unique_ptr<DIR, int (*)(DIR*)> dir{::opendir(dir_name.c_str()),
120-
&::closedir};
121-
if (dir == nullptr) {
122-
const int ret =
123-
#ifdef _WIN32
124-
::_mkdir(dir_name.c_str());
125-
#else
126-
::mkdir(dir_name.c_str(), 0777);
127-
#endif
128-
if (ret != 0) {
129-
throw databento::Exception{std::string{"Unable to create directory "} +
130-
dir_name + ": " + ::strerror(errno)};
131-
}
116+
std::error_code ec{};
117+
if (std::filesystem::create_directory(dir_name, ec) || !ec) {
118+
// Successfully created directory or it already exists
119+
return;
132120
}
121+
throw databento::Exception{"Unable to create directory "s +
122+
dir_name.generic_string() + ": " + ec.message()};
133123
}
134124

135125
std::string PathJoin(const std::string& dir, const std::string& path) {

vcpkg.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
33
"name": "databento",
44
"dependencies": [
5-
{
6-
"name": "dirent",
7-
"platform": "windows"
8-
},
95
"openssl",
106
"zstd"
117
],

0 commit comments

Comments
 (0)