Heh - I was just going to ask the same Python-binding question :-)
Also: in one case I want to check if a file name is on a local directory (ie. not on gvfs mount) and then get the directory of the file... Currently I use this:
if theUri.startswith("file:///"): theDir = os.path.dirname(theUri[7:])
Not elegant, and uses a hardcoded file:/ prefix... Any suggestion how to improve this?
4 February 2009 at 16:18
Anonymous said...
oliver: use g_file_is_native()
/ Alex
4 February 2009 at 19:37
Anonymous said...
You can also use g_file_get_path() if it returns Non-NULL its a local path. If you do it this way it can return local paths for gvfs mounts too, via fuse. (but is_native() will return FALSE even if fuse is availible).
Things you shouldn't ever be doing. Transform a filename into a URI like that:uri = g_strdup_printf ("file:///%s", filename);
Use g_filename_to_uri() instead. Same goes for the opposite direction, where stripping "file://" isn't good enough to transform a URI into a local filename. Use g_filename_from_uri(), or g_file_get_path() if you're actually going to be opening the files.
Use GStreamer to play a single small pop sound:Use libcanberra instead. It's portable, might use GStreamer in some cases, and very certainly requires less code for a simple use like this.
Bruno, you should get a Bugzilla component for Garfunkel.
"Things you shouldn't do"
6 Comments -
Is there a python binding for this
4 February 2009 at 16:09
Heh - I was just going to ask the same Python-binding question :-)
Also: in one case I want to check if a file name is on a local directory (ie. not on gvfs mount) and then get the directory of the file... Currently I use this:
if theUri.startswith("file:///"):
theDir = os.path.dirname(theUri[7:])
Not elegant, and uses a hardcoded file:/ prefix... Any suggestion how to improve this?
4 February 2009 at 16:18
oliver:
use g_file_is_native()
/ Alex
4 February 2009 at 19:37
You can also use g_file_get_path() if it returns Non-NULL its a local path. If you do it this way it can return local paths for gvfs mounts too, via fuse. (but is_native() will return FALSE even if fuse is availible).
4 February 2009 at 19:52
Thank you, Bastien!
4 February 2009 at 20:46
> Use libcanberra instead.
Or Phonon. :-)
5 February 2009 at 12:41