How to open remote files for searching in them


I’m trying to migrate away from GnomeVFS to GIO in my application. One issue I’m trying to solve is to search in files for the occurrence of a string. In the GIO documentation it says that I could use g_file_open_readwrite() for opening the files. But in its documentation it says:

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

To me this statement is a bit unclear.

  1. How would a remote file be opened without using streams? Is there a separate function available in GIO? I know that g_open() exists, but this seems to be only applicable for local files, right? For example, how can I open a file through a samba share (smb://...) for searching in it, without using the GIO method mentioned in the beginning?
  2. When a non-streamable file should be opened via g_file_open_readwrite(), would this error case be reported in the GError argument?

Thank you

Searching is reading, so you may try

1 Like

Oha :relaxed: Thanks for that. I only searched for “open” in the documentation, …

open_readwrite is a bit of an odd one out, GFile has a number of “open” methods

  • append_to
  • create
  • create_readwrite
  • open_readwrite
  • read
  • replace
  • replace_readwrite
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.