Skip to content

Commit

Permalink
fix windows and format
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Nov 5, 2024
1 parent babf88f commit 33b99a8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2102,8 +2102,8 @@ static void ReaddirRecursiveSync(const FunctionCallbackInfo<Value>& args) {
while (!dir_queue.empty()) {
std::string current_path = std::move(dir_queue.back());
dir_queue.pop_back();
int err = uv_fs_scandir(nullptr, &req_wrap_sync.req,
current_path.c_str(), 0, nullptr);
int err = uv_fs_scandir(
nullptr, &req_wrap_sync.req, current_path.c_str(), 0, nullptr);
if (err < 0) {
if (err == UV_ENOENT || err == UV_ENOTDIR) {
continue;
Expand All @@ -2119,7 +2119,7 @@ static void ReaddirRecursiveSync(const FunctionCallbackInfo<Value>& args) {
}

std::string full_path = current_path;
if (full_path.back() != kPathSeparator) {
if (full_path.back() != kPathSeparator[0]) {
full_path += kPathSeparator;
}
full_path += ent.name;
Expand All @@ -2132,7 +2132,7 @@ static void ReaddirRecursiveSync(const FunctionCallbackInfo<Value>& args) {
size_t full_path_length = full_path.length();
if (full_path_length > base_path_length) {
size_t start_pos = base_path_length;
if (full_path[start_pos] == kPathSeparator) {
if (full_path[start_pos] == kPathSeparator[0])
start_pos++;
}
if (start_pos < full_path_length) {
Expand All @@ -2148,39 +2148,39 @@ static void ReaddirRecursiveSync(const FunctionCallbackInfo<Value>& args) {
}

const size_t result_size =
with_file_types ? paths.size() : relative_paths.size();
with_file_types ? paths.size() : relative_paths.size();
std::vector<Local<Value>> result_entries(result_size);

if (with_file_types) {
for (size_t i = 0; i < result_size; i++) {
Local<Array> entry_info = Array::New(isolate, 3);
Local<Value> error;

MaybeLocal<Value> path_value = StringBytes::Encode(isolate,
paths[i].c_str(), encoding, &error);
MaybeLocal<Value> path_value =
StringBytes::Encode(isolate, paths[i].c_str(), encoding, &error);
if (!error.IsEmpty()) {
isolate->ThrowException(error);
return;
}

MaybeLocal<Value> name_value = StringBytes::Encode(isolate,
names[i].c_str(), encoding, &error);
MaybeLocal<Value> name_value =
StringBytes::Encode(isolate, names[i].c_str(), encoding, &error);
if (!error.IsEmpty()) {
isolate->ThrowException(error);
return;
}

entry_info->Set(env->context(), 0, path_value.ToLocalChecked()).Check();
entry_info->Set(env->context(), 1, name_value.ToLocalChecked()).Check();
entry_info->Set(env->context(), 2,
Integer::New(isolate, types[i])).Check();
entry_info->Set(env->context(), 2, Integer::New(isolate, types[i]))
.Check();
result_entries[i] = entry_info;
}
} else {
for (size_t i = 0; i < result_size; i++) {
Local<Value> error;
MaybeLocal<Value> path_value = StringBytes::Encode(isolate,
relative_paths[i].c_str(), encoding, &error);
MaybeLocal<Value> path_value = StringBytes::Encode(
isolate, relative_paths[i].c_str(), encoding, &error);
if (!error.IsEmpty()) {
isolate->ThrowException(error);
return;
Expand Down

0 comments on commit 33b99a8

Please sign in to comment.