gboolean
modest_utils_file_exists (const gchar *filename)
{
- GnomeVFSURI *uri = NULL;
gboolean result = FALSE;
+ gchar *path;
g_return_val_if_fail (filename, FALSE);
- uri = gnome_vfs_uri_new (filename);
- if (uri) {
- result = gnome_vfs_uri_exists (uri);
- gnome_vfs_uri_unref (uri);
- }
+ path = strstr (filename, "file://");
+ if (!path)
+ path = (gchar *) filename;
+ else
+ path = (gchar *) filename + strlen ("file://");
+
+ if (g_access (path, F_OK) == 0)
+ result = TRUE;
+
return result;
}
return NULL;
}
- if (g_strstr_len (orig_name, strlen(orig_name), "/") != NULL) {
+ if (g_strstr_len (orig_name, strlen (orig_name), "/") != NULL) {
g_warning ("%s: filename contains '/' character(s) (%s)",
__FUNCTION__, orig_name);
return NULL;
return NULL;
}
- filepath = g_strconcat (tmpdir, "/", orig_name, NULL);
+ filepath = g_build_filename (tmpdir, orig_name, NULL);
/* if file exists, first we try to remove it */
- if (modest_utils_file_exists (filepath)) {
+ if (g_access (filepath, F_OK) == 0)
g_unlink (filepath);
- }
/* don't overwrite if it already exists, even if it is writable */
- if (modest_utils_file_exists (filepath)) {
+ if (g_access (filepath, F_OK) == 0) {
if (path!=NULL) {
*path = filepath;
} else {