Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions c_glib/arrow-glib/file-system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,26 @@ garrow_file_system_register_type(const gchar *type_name, GType gtype, GError **e
return TRUE;
}

/**
* garrow_file_system_ensure_finalized:
*
* Finalize all registered Arrow C++ file system implementations.
*
* Call this function during application shutdown, after file system
* operations have finished and streams have been closed. Do not use
* file system APIs after this call.
*
* The caller is responsible for synchronizing this call with other
* file system activity.
*
* Since: 27.0.0
*/
void
garrow_file_system_ensure_finalized(void)
{
arrow::fs::EnsureFinalized();
}

/**
* garrow_file_system_create:
* @uri: An URI to specify file system with options. If you only have an
Expand Down
4 changes: 4 additions & 0 deletions c_glib/arrow-glib/file-system.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ GARROW_AVAILABLE_IN_27_0
gboolean
garrow_file_system_register_type(const gchar *type_name, GType gtype, GError **error);

GARROW_AVAILABLE_IN_27_0
void
garrow_file_system_ensure_finalized(void);

GARROW_AVAILABLE_IN_3_0
GArrowFileSystem *
garrow_file_system_create(const gchar *uri, GError **error);
Expand Down
23 changes: 23 additions & 0 deletions c_glib/test/test-file-system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,27 @@ def test_unrelated_type
end
end
end

sub_test_case(".ensure_finalized") do
def test_create_after_finalization
# Finalization affects the whole process, so isolate it from the test runner.
pid = spawn(RbConfig.ruby, "-e", <<-SCRIPT)
require "gi"
require "test/unit/assertions"

include Test::Unit::Assertions

Gio = GI.load("Gio")
Arrow = GI.load("Arrow")

Arrow::FileSystem.create("mock://")
Arrow::FileSystem.ensure_finalized
assert_raise(Arrow::Error::Invalid) do
Arrow::FileSystem.create("mock://")
end
SCRIPT
_, status = Process.wait2(pid)
assert_predicate(status, :success?)
end
end
end
Loading