Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » GTK+
  • » How to get file type when G_FILE_MONITOR_EVENT_DELETED? [RSS Feed]

#1 Dec. 12, 2010 08:12:43

Vikram A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How to get file type when G_FILE_MONITOR_EVENT_DELETED?


How do you figure out the file type inside GFileMonitor's "changed"callback when the GFileMonitorEvent is a G_FILE_MONITOR_EVENT_DELETED?I was erroneously using g_file_query_file_type()!=G_FILE_TYPE_DIRECTORY,without actually looking at the return value, until recently discoveredthat since the GFile in question has just been deleted, it would alwaysreturn G_FILE_TYPE_UNKNOWN.Vikram.
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 Dec. 12, 2010 10:11:09

Lex T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How to get file type when G_FILE_MONITOR_EVENT_DELETED?


On 12 December 2010 19:09, Vikram Ambrose <noel.ambr***@*mail.com> wrote:
> How do you figure out the file type inside GFileMonitor's "changed" callback
> when the GFileMonitorEvent is a G_FILE_MONITOR_EVENT_DELETED?
>
> I was erroneously using g_file_query_file_type()!=G_FILE_TYPE_DIRECTORY,
> without actually looking at the return value, until recently discovered that
> since the GFile in question has just been deleted, it would always return
> G_FILE_TYPE_UNKNOWN.

A deleted file doesn't exist so it doesn't have a type. Since the
event is telling you the file is deleted you already know this and
don't need to query the type (or you can use the fact that
G_FILE_TYPE_UNKNOWN is documented to mean does not exist.

Cheers
Lex

>
>
> Vikram.
> _______________________________________________
> gtk-list mailing list
> gtk-l***@*nome.org
>http://mail.gnome.org/mailman/listinfo/gtk-list>
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#3 Dec. 12, 2010 20:11:59

Vikram A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How to get file type when G_FILE_MONITOR_EVENT_DELETED?


On 12/12/2010 05:10 AM, Lex Trotman wrote:On 12 December 2010 19:09, Vikram Ambrose<noel.ambr***@*mail.com> wrote:How do you figure out the file type inside GFileMonitor's "changed" callback
when the GFileMonitorEvent is a G_FILE_MONITOR_EVENT_DELETED?

I was erroneously using g_file_query_file_type()!=G_FILE_TYPE_DIRECTORY,
without actually looking at the return value, until recently discovered that
since the GFile in question has just been deleted, it would always return
G_FILE_TYPE_UNKNOWN.A deleted file doesn't exist so it doesn't have a type. Since the
event is telling you the file is deleted you already know this and
don't need to query the type (or you can use the fact that
G_FILE_TYPE_UNKNOWN is documented to mean does not exist.I don't understand what you mean by "don't need to query the type". Iwant to know if the _EVENT_DELETED was for a regular file or a directory.Does this mean that I would need to service "changed" for directorieswith a different callback from what I use for regular files just to beable to differentiate between the file types for this event?/V
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#4 Dec. 12, 2010 23:21:44

Lex T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How to get file type when G_FILE_MONITOR_EVENT_DELETED?


On 13 December 2010 07:08, Vikram Ambrose <noel.ambr***@*mail.com> wrote:
> On 12/12/2010 05:10 AM, Lex Trotman wrote:
>>
>> On 12 December 2010 19:09, Vikram Ambrose<noel.ambr***@*mail.com>  wrote:
>>>
>>> How do you figure out the file type inside GFileMonitor's "changed"
>>> callback
>>> when the GFileMonitorEvent is a G_FILE_MONITOR_EVENT_DELETED?
>>>
>>> I was erroneously using g_file_query_file_type()!=G_FILE_TYPE_DIRECTORY,
>>> without actually looking at the return value, until recently discovered
>>> that
>>> since the GFile in question has just been deleted, it would always return
>>> G_FILE_TYPE_UNKNOWN.
>>
>> A deleted file doesn't exist so it doesn't have a type.  Since the
>> event is telling you the file is deleted you already know this and
>> don't need to query the type (or you can use the fact that
>> G_FILE_TYPE_UNKNOWN is documented to mean does not exist.
>>
>
> I don't understand what you mean by "don't need to query the type". I want
> to know if the _EVENT_DELETED was for a regular file or a directory.
>
> Does this mean that I would need to service "changed" for directories with a
> different callback from what I use for regular files just to be able to
> differentiate between the file types for this event?

Yes or set different user_data when you connect to the monitor.

Cheers
Lex

>
>
> /V
> _______________________________________________
> gtk-list mailing list
> gtk-l***@*nome.org
>http://mail.gnome.org/mailman/listinfo/gtk-list>
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

  • Root
  • » GTK+
  • » How to get file type when G_FILE_MONITOR_EVENT_DELETED? [RSS Feed]

Board footer

Moderator control

Enjoy the 21st of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support