Skip to content

Commit

Permalink
Add dir.exists? exception to Directory.list
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmalonenz committed Feb 19, 2024
1 parent c78b884 commit ce256cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stdlib/directory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ VALUE dir_static_list(VM *vm, VALUE UNUSED(klass), int arg_count, VALUE *argumen
else
{
throw_exception_native(vm, "ArgumentException", "Directory.list only accepts a String or a Directory object");
return NIL_VAL;
}

if (!std::filesystem::exists(path)) {
throw_exception_native(vm, "IOException", "Directory '%s' not found", path);
return NIL_VAL;
}

VALUE result = list_create(vm);
Expand Down

0 comments on commit ce256cc

Please sign in to comment.