goto save_error;
/* open tmpfile(r) */
- text_uri = g_strconcat("file://", tmpfile, NULL);
+ text_uri = file2uri(tmpfile);
if (gnome_vfs_open(&tmp_handle, text_uri, GNOME_VFS_OPEN_READ) != GNOME_VFS_OK)
{
text_uri = NULL;
/* open/create newfile for writing */
- text_uri = g_strconcat("file://", newfile_tmp, NULL);
+ text_uri = file2uri(newfile_tmp);
uri = gnome_vfs_uri_new(text_uri);
g_free(text_uri);
text_uri = NULL;
* - the tmpfile where the raw data is (or the same file name if the file was raw)
* TODO: add parameter (GError?) to report back an error string
*/
-gboolean openFile(const gchar *filename, AudioFormat *format, gchar **tmpfile)
+gboolean
+openFile(const gchar *filename, AudioFormat *format, gchar **tmpfile)
{
if (g_strrstr(filename, EXTENSION_PCMA))
{
{
ULOG_INFO("%s() - file was %s", G_STRFUNC, EXTENSION_WAV);
*format = FORMAT_WAV;
+ /* TODO: we should dig out the rate, channels and stuff from the WAV file here or get the caps from some GstPad */
*tmpfile = g_strdup(filename);
}
else if (g_strrstr(filename, EXTENSION_ILBC))
ULOG_INFO("%s() - file was AU/SND", G_STRFUNC);
/* decode and extract raw AU data */
- text_uri = g_strdup_printf("file://%s", filename);
+ text_uri = file2uri(filename);
if (gnome_vfs_open(&from_handle, text_uri, GNOME_VFS_OPEN_READ) != GNOME_VFS_OK)
{
ULOG_WARN("%s() - gnome_vfs_open() failed", G_STRFUNC);
return TRUE;
}
-GnomeVFSFileSize getFileLength(const gchar *file)
+GnomeVFSFileSize
+getFileLength(const gchar *file)
{
GnomeVFSFileInfo *info;
GnomeVFSResult res;
if (NULL == file)
return ret;
- text_uri = g_strdup_printf("file://%s", file);
+ text_uri = file2uri(file);
info = gnome_vfs_file_info_new();
res = gnome_vfs_get_file_info(text_uri,
info,
return ret;
}
+
+gchar *
+file2uri(const gchar *filename)
+{
+ if (NULL == filename)
+ return NULL;
+
+ if (g_str_has_prefix(filename, "file://"))
+ return g_strdup(filename);
+
+ /*
+ return g_strconcat("file://", filename, NULL);
+ */
+ return g_filename_to_uri(filename, NULL, NULL);
+}