Skip to content

Commit

Permalink
Fix File.info(File::NULL) on Windows (#13421)
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed May 3, 2023
1 parent b65280a commit 3226a35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 1 addition & 2 deletions spec/std/file_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,7 @@ describe "File" do
info.type.should eq(File::Type::Directory)
end

# TODO: support stating nul on windows
pending_win32 "gets for a character device" do
it "gets for a character device" do
info = File.info(File::NULL)
info.type.should eq(File::Type::CharacterDevice)
end
Expand Down
6 changes: 1 addition & 5 deletions src/crystal/system/win32/file.cr
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ module Crystal::System::File
return check_not_found_error("Unable to get file info", path) if handle == LibC::INVALID_HANDLE_VALUE

begin
if LibC.GetFileInformationByHandle(handle, out file_info) == 0
raise ::File::Error.from_winerror("Unable to get file info", file: path)
end

::File::Info.new(file_info, LibC::FILE_TYPE_DISK)
FileDescriptor.system_info(handle)
ensure
LibC.CloseHandle(handle)
end
Expand Down

0 comments on commit 3226a35

Please sign in to comment.