# Problem with using GLib::File

**URL:** <https://www.ruby-forum.com/t/problem-with-using-glib-file/207937>\
**Category:** Ruby-Gnome 2\
**Created:** [June 6, 2011, 7:21pm UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937 "2011-06-06T19:21:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 6, 2011, 7:21pm UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937/1 "2011-06-06T19:21:17Z")

</div>

Hello

I tried to put together a test application that opens a file.

Unfortunately, the line with GLib::File.read returns:

fdialog.rb:16:in `filechooserbutton1\_file\_set\_cb’: uninitialized  
constant GLib::File

I use

require ‘libglade2’  
require ‘glib2’

what do I need to read a file?

Where can I find the required library for an object like GLib::File?

The page [http://ruby-gnome2.sourceforge.jp/hiki.cgi?GLib%3A%3AFile](http://ruby-gnome2.sourceforge.jp/hiki.cgi?GLib%3A%3AFile)  
does not state requirements.

Thanks

Michal

---

<div class="post-metadata">

**Author:** ![Michal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@Michal\_S](https://www.ruby-forum.com/u/Michal_S)\
**Post date:** [June 6, 2011, 8:56pm UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937/2 "2011-06-06T20:56:34Z")

</div>

Subject: [ruby-gnome2-devel-en] problem with using GLib::File  
Date: lun 06 giu 11 07:20:12 +0200

Quoting Michal S. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> require ‘glib2’
> 
> what do I need to read a file?

The File class is included in the default Ruby library, not in Glib.

You must use File in place of GLib::File if you want your program to  
access files.

Carlo

–

- 

```
    Se la Strada e la sua Virtu' non fossero state messe da 

```

parte,

- K \* Carlo E. Prelz - [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) che bisogno ci  
sarebbe
  - 

```
          di parlare tanto di amore e di rettitudine? 

```

(Chuang-Tzu)

---

<div class="post-metadata">

**Author:** ![Michal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@Michal\_S](https://www.ruby-forum.com/u/Michal_S)\
**Post date:** [June 7, 2011, 9:07am UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937/3 "2011-06-07T09:07:49Z")

</div>

On 6 June 2011 20:29, Carlo E. Prelz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > constant GLib::File  
> > You must use File in place of GLib::File if you want your program to  
> > access files.
> 
> Carlo

Then my program won’t be able to access my files because they are only  
reachable through gvfs.

Thanks

Michal

---

<div class="post-metadata">

**Author:** ![Michal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@Michal\_S](https://www.ruby-forum.com/u/Michal_S)\
**Post date:** [June 8, 2011, 8:59pm UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937/4 "2011-06-08T20:59:53Z")

</div>

Michal S. wrote in post #1003626:

> Then my program won’t be able to access my files because they are only  
> reachable through gvfs.

have you tried ruby/gnomevfs? never used it myself, but looks like it  
could work for you…

[http://ruby-gnome2.sourceforge.jp/hiki.cgi?Ruby/GnomeVFS](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Ruby/GnomeVFS)

cheers,

- j

---

<div class="post-metadata">

**Author:** ![Michal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@Michal\_S](https://www.ruby-forum.com/u/Michal_S)\
**Post date:** [June 7, 2011, 12:26pm UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937/5 "2011-06-07T12:26:52Z")

</div>

On 7 June 2011 09:07, Michal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > fdialog.rb:16:in `filechooserbutton1\_file\_set\_cb’: uninitialized
> > 
> > You must use File in place of GLib::File if you want your program to  
> > access files.
> > 
> > Carlo
> 
> Then my program won’t be able to access my files because they are only  
> reachable through gvfs.

Also, what does  
[http://ruby-gnome2.sourceforge.jp/hiki.cgi?GLib%3A%3AFile](http://ruby-gnome2.sourceforge.jp/hiki.cgi?GLib%3A%3AFile) describe?

A non-existent module?

Thanks

Michal

---

<div class="post-metadata">

**Author:** ![Michal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@Michal\_S](https://www.ruby-forum.com/u/Michal_S)\
**Post date:** [June 12, 2011, 10:08pm UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937/6 "2011-06-12T22:08:45Z")

</div>

On Mon, Jun 6, 2011 at 19:20, Michal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> what do I need to read a file?

require ‘gio2’

---

<div class="post-metadata">

**Author:** ![Michal\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@Michal\_S](https://www.ruby-forum.com/u/Michal_S)\
**Post date:** [June 29, 2011, 2:15pm UTC](https://www.ruby-forum.com/t/problem-with-using-glib-file/207937/7 "2011-06-29T14:15:06Z")

</div>

Hello

On 12 June 2011 22:08, Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Mon, Jun 6, 2011 at 19:20, Michal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > what do I need to read a file?
> 
> require ‘gio2’

with recent ruby-gnome2 I get gio2 which provides the GLib::File module.

(GLib::File.new\_for\_uri uri).read.close returns true so I guess I can  
read files.

Thanks

Michal
