Skip to content

Commit dbeee13

Browse files
author
lishuo121
committed
fix: code format
1 parent b513e93 commit dbeee13

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

include/ylt/coro_io/coro_file.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,24 @@ constexpr inline flags to_flags(std::ios::ios_base::openmode mode) {
124124
#if defined(ASIO_HAS_FILE)
125125
template <bool seq, typename File, typename Executor>
126126
inline bool open_native_async_file(File &file, Executor &executor,
127-
std::string_view filepath,
128-
flags open_flags, bool use_direct_io = false) {
127+
std::string_view filepath, flags open_flags,
128+
bool use_direct_io = false) {
129129
if (file && file->is_open()) {
130130
return true;
131131
}
132132

133133
try {
134-
asio::file_base::flags asio_flags = static_cast<asio::file_base::flags>(open_flags);
135-
134+
asio::file_base::flags asio_flags =
135+
static_cast<asio::file_base::flags>(open_flags);
136+
136137
if (use_direct_io) {
137138
#if defined(ASIO_WINDOWS)
138139
#elif defined(__linux__)
139140
asio_flags = static_cast<asio::file_base::flags>(
140141
static_cast<int>(asio_flags) | O_DIRECT);
141142
#endif
142143
}
143-
144+
144145
if constexpr (seq) {
145146
file = std::make_shared<asio::stream_file>(
146147
executor.get_asio_executor(), std::string(filepath), asio_flags);
@@ -149,7 +150,7 @@ inline bool open_native_async_file(File &file, Executor &executor,
149150
file = std::make_shared<asio::random_access_file>(
150151
executor.get_asio_executor(), std::string(filepath), asio_flags);
151152
}
152-
153+
153154
// On macOS, use F_NOCACHE as an alternative to O_DIRECT
154155
if (use_direct_io && file && file->is_open()) {
155156
#if defined(__APPLE__) || defined(__MACH__)
@@ -423,8 +424,8 @@ class basic_random_coro_file {
423424
open(filepath, open_flags);
424425
}
425426

426-
bool open(std::string_view filepath,
427-
std::ios::ios_base::openmode open_flags, bool use_direct_io = false) {
427+
bool open(std::string_view filepath, std::ios::ios_base::openmode open_flags,
428+
bool use_direct_io = false) {
428429
file_path_ = std::string{filepath};
429430
if constexpr (execute_type == execution_type::thread_pool) {
430431
return open_fd(filepath, to_flags(open_flags), use_direct_io);
@@ -538,7 +539,8 @@ class basic_random_coro_file {
538539
std::string_view file_path() const { return file_path_; }
539540

540541
private:
541-
bool open_fd(std::string_view filepath, int open_flags, bool use_direct_io = false) {
542+
bool open_fd(std::string_view filepath, int open_flags,
543+
bool use_direct_io = false) {
542544
if (prw_random_file_) {
543545
return true;
544546
}

src/coro_io/tests/test_corofile.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,9 @@ void test_direct_io_read_write(std::string_view filename) {
10011001

10021002
std::error_code write_ec;
10031003
size_t bytes_written;
1004-
std::tie(write_ec, bytes_written) = async_simple::coro::syncAwait(
1005-
file.async_write_at(aligned_offset, std::string_view(buf, aligned_read_size)));
1004+
std::tie(write_ec, bytes_written) =
1005+
async_simple::coro::syncAwait(file.async_write_at(
1006+
aligned_offset, std::string_view(buf, aligned_read_size)));
10061007

10071008
CHECK(!write_ec);
10081009
CHECK(bytes_written == aligned_read_size);

0 commit comments

Comments
 (0)