Brian Manning
and 1 contributors

NAME

Glib::IO - Perl bindings to the GIO library

SYNOPSIS

  use Glib;
  use Glib::IO;

  # Synchronous I/O
  $cur_dir = Glib::IO::File::new_for_path('.');
  $enumerator = $cur_dir->enumerate_children('standard::*', [], undef);
  $file_info = $enumerator->next_file(undef);
  while ($next_file) {
      say 'Path: ' + $file_info->get_name();
  }

  # Asynchronous I/O
  $loop = Glib::MainLoop->new();
  $file = Glib::IO::File::new_for_path('/etc/passwd');
  $file->query_info_async('access::can-read,access::can-write', [], 0, sub {
      my ($file, $res, $data) = @_;
      my $info = $file->query_info_finish();
      say 'Can read:  ' + $info->get_attribute_boolean('access::can-read');
      say 'Can write: ' + $info->get_attribute_boolean('access::can-write');
      $loop->quit();
  }
  $loop->run();

  # Platform API
  $network_monitor = Glib::IO::NetworkMonitor::get_default();
  say 'Connected: ', $network_monitor->get_network_available() ? 'Yes' : 'No';

ABSTRACT

Perl bindings to the GIO library. This modules allows you to write portable code to perform synchronous and asynchronous I/O; implement IPC clients and servers using the DBus specification; interact with the operating system and platform using various services.

DESCRIPTION

The Glib::IO module allows a Perl developer to access the GIO library, the high level I/O and platform library of the GNOME development platform. GIO is used for:

  • local and remote enumeration and access of files

    GIO has multiple backends to access local file systems; SMB/CIFS volumes; WebDAV resources; compressed archives; local devices and remote web services.

  • stream based I/O

    Including files, memory buffers, and network streams.

  • low level and high level network operations

    Sockets, Internet addresses, datagram-based connections, and TCP connections.

  • TLS/SSL support for socket connections

  • DNS resolution and proxy

  • low level and high level DBus classes

    GIO allows the implementation of clients and servers, as well as proxying objects over DBus connections.

Additionally, GIO has a collection of high level classes for writing applications that integrate with the platform, like:

settings
network monitoring
a base Application class
extensible data models
content type matching
application information and launch

For more information, please visit the GIO reference manual available on https://developer.gnome.org/gio/stable. The Perl API closely matches the C one, and eventual deviations will be documented here.

The principles underlying the mapping from C to Perl are explained in the documentation of Glib::Object::Introspection, on which Glib::IO is based.

Glib::Object::Introspection also comes with the perli11ndoc program which displays the API reference documentation of all installed libraries organized in accordance with these principles.

SEE ALSO

AUTHORS

Torsten Schönfeld <kaffeetisch@gmx.de>
Emmanuele Bassi <ebassi@gnome.org>

COPYRIGHT AND LICENSE

Copyright (C) 2010-2015 by Torsten Schönfeld <kaffeetisch@gmx.de> Copyright 2017 Emmanuele Bassi

This library is free software; you can redistribute it and/or modify it under the terms of the Lesser General Public License (LGPL). For more information, see http://www.fsf.org/licenses/lgpl.txt