2626
2727#include " async_simple/coro/SyncAwait.h"
2828#include " io_context_pool.hpp"
29- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
29+ #if defined(ASIO_HAS_FILE )
3030#include < asio/random_access_file.hpp>
3131#include < asio/stream_file.hpp>
3232#endif
@@ -121,7 +121,7 @@ constexpr inline flags to_flags(std::ios::ios_base::openmode mode) {
121121 return access;
122122}
123123
124- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
124+ #if defined(ASIO_HAS_FILE )
125125template <bool seq, typename File, typename Executor>
126126inline bool open_native_async_file (File &file, Executor &executor,
127127 std::string_view filepath,
@@ -184,7 +184,7 @@ class basic_seq_coro_file {
184184 return open_stream_file_in_pool (filepath, open_flags);
185185 }
186186 else {
187- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
187+ #if defined(ASIO_HAS_FILE )
188188 return open_native_async_file<true >(async_seq_file_, executor_wrapper_,
189189 filepath, to_flags (open_flags));
190190#else
@@ -199,7 +199,7 @@ class basic_seq_coro_file {
199199 co_return co_await async_read_write ({buf, size});
200200 }
201201 else {
202- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
202+ #if defined(ASIO_HAS_FILE )
203203 if (async_seq_file_ == nullptr ) {
204204 co_return std::make_pair (
205205 std::make_error_code (std::errc::invalid_argument), 0 );
@@ -253,7 +253,7 @@ class basic_seq_coro_file {
253253 std::span (const_cast <char *>(buf.data ()), buf.size ()));
254254 }
255255 else {
256- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
256+ #if defined(ASIO_HAS_FILE )
257257 if (async_seq_file_ == nullptr ) {
258258 co_return std::make_pair (
259259 std::make_error_code (std::errc::invalid_argument), 0 );
@@ -268,7 +268,7 @@ class basic_seq_coro_file {
268268 }
269269 }
270270
271- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
271+ #if defined(ASIO_HAS_FILE )
272272 std::shared_ptr<asio::stream_file> get_async_stream_file () {
273273 return async_seq_file_;
274274 }
@@ -277,7 +277,7 @@ class basic_seq_coro_file {
277277 std::fstream &get_stream_file () { return frw_seq_file_; }
278278
279279 bool is_open () {
280- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
280+ #if defined(ASIO_HAS_FILE )
281281 if (async_seq_file_ && async_seq_file_->is_open ()) {
282282 return true ;
283283 }
@@ -288,7 +288,7 @@ class basic_seq_coro_file {
288288 bool eof () { return eof_; }
289289
290290 void close () {
291- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
291+ #if defined(ASIO_HAS_FILE )
292292 if (async_seq_file_ && async_seq_file_->is_open ()) {
293293 std::error_code ec;
294294 async_seq_file_->close (ec);
@@ -300,7 +300,7 @@ class basic_seq_coro_file {
300300 }
301301
302302 bool seek (size_t offset, std::ios_base::seekdir dir) {
303- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
303+ #if defined(ASIO_HAS_FILE )
304304 if (async_seq_file_ && async_seq_file_->is_open ()) {
305305 int whence = SEEK_SET ;
306306 if (dir == std::ios_base::cur)
@@ -327,7 +327,7 @@ class basic_seq_coro_file {
327327 }
328328
329329 execution_type get_execution_type () {
330- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
330+ #if defined(ASIO_HAS_FILE )
331331 if (async_seq_file_ && async_seq_file_->is_open ()) {
332332 return execution_type::native_async;
333333 }
@@ -370,7 +370,7 @@ class basic_seq_coro_file {
370370 }
371371
372372 coro_io::ExecutorWrapper<> executor_wrapper_;
373- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
373+ #if defined(ASIO_HAS_FILE )
374374 std::shared_ptr<asio::stream_file> async_seq_file_; // seq
375375#endif
376376 std::fstream frw_seq_file_; // fread/fwrite seq file
@@ -411,7 +411,7 @@ class basic_random_coro_file {
411411 return open_fd (filepath, to_flags (open_flags));
412412 }
413413 else {
414- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
414+ #if defined(ASIO_HAS_FILE )
415415 return open_native_async_file<false >(async_random_file_,
416416 executor_wrapper_, filepath,
417417 to_flags (open_flags));
@@ -427,7 +427,7 @@ class basic_random_coro_file {
427427 co_return co_await async_pread (offset, buf, size);
428428 }
429429 else {
430- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
430+ #if defined(ASIO_HAS_FILE )
431431 if (async_random_file_ == nullptr ) {
432432 co_return std::make_pair (
433433 std::make_error_code (std::errc::invalid_argument), 0 );
@@ -453,7 +453,7 @@ class basic_random_coro_file {
453453 co_return co_await async_pwrite (offset, buf.data (), buf.size ());
454454 }
455455 else {
456- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
456+ #if defined(ASIO_HAS_FILE )
457457 if (async_random_file_ == nullptr ) {
458458 co_return std::make_pair (
459459 std::make_error_code (std::errc::invalid_argument), 0 );
@@ -468,7 +468,7 @@ class basic_random_coro_file {
468468 }
469469 }
470470
471- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
471+ #if defined(ASIO_HAS_FILE )
472472 std::shared_ptr<asio::random_access_file> get_async_stream_file () {
473473 return async_random_file_;
474474 }
@@ -477,7 +477,7 @@ class basic_random_coro_file {
477477 std::shared_ptr<int > get_pread_file () { return prw_random_file_; }
478478
479479 bool is_open () {
480- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
480+ #if defined(ASIO_HAS_FILE )
481481 if (async_random_file_ && async_random_file_->is_open ()) {
482482 return true ;
483483 }
@@ -488,7 +488,7 @@ class basic_random_coro_file {
488488 bool eof () { return eof_; }
489489
490490 execution_type get_execution_type () {
491- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
491+ #if defined(ASIO_HAS_FILE )
492492 if (async_random_file_ && async_random_file_->is_open ()) {
493493 return execution_type::native_async;
494494 }
@@ -501,7 +501,7 @@ class basic_random_coro_file {
501501 }
502502
503503 void close () {
504- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
504+ #if defined(ASIO_HAS_FILE )
505505 std::error_code ec;
506506 if (async_random_file_) {
507507 async_random_file_->close (ec);
@@ -653,7 +653,7 @@ class basic_random_coro_file {
653653#endif
654654
655655 coro_io::ExecutorWrapper<> executor_wrapper_;
656- #if defined(ENABLE_FILE_IO_URING) || defined(ASIO_WINDOWS )
656+ #if defined(ASIO_HAS_FILE )
657657 std::shared_ptr<asio::random_access_file> async_random_file_; // random file
658658#endif
659659 std::shared_ptr<int > prw_random_file_ = nullptr ; // pread/pwrite random file
0 commit comments