Commit 17955b15 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler

reviewed by: Gene Z. Ragan <gzr@eazel.com>

2001-01-31  Pavel Cisler  <pavel@eazel.com>

	reviewed by: Gene Z. Ragan <gzr@eazel.com>

	Fix 5324 (Should get rid of stack-based GnomeVFSFileInfo)

	* components/adapter/bonobo-stream-vfs.c: (vfs_get_info):
	Nuked some unused code that contained gnome_vfs_file_info_init.

	* components/adapter/nautilus-adapter-progressive-load-strategy.c:
	(nautilus_adapter_progressive_load_strategy_load_location):
	* libnautilus-extensions/nautilus-icon-factory.c:
	(path_represents_svg_image), (get_cache_time):
	* libnautilus-extensions/nautilus-thumbnails.c:
	(first_file_more_recent):
	* src/nautilus-window-menus.c: (get_static_bookmarks_file_path):
	Get rid of gnome_vfs_file_info_init.
	Replace all instances of stack-based GnomeVFSFileInfo
	structures, replace all calls to gnome_vfs_file_info_init
	with gnome_vfs_file_info_new.
	Replace most calls to gnome_vfs_file_info_clear with
	gnome_vfs_file_info_unref.

	* libnautilus-extensions/nautilus-preferences-item.c:
	(has_image_file):
	Rework to use gnome_vfs_uri_exists instead of trying to get
	file info.

	* components/adapter/nautilus-adapter-progressive-load-strategy.c:
	(nautilus_adapter_progressive_load_strategy_load_location):
	Fixed a bug where file info fields were being used after a
	gnome_vfs_file_info_clear call


	Fix 6146 ("Duplicate File" reports "You cannot copy a file
		   over itself")

	* libnautilus-extensions/nautilus-file-operations.c:
	(nautilus_file_operations_copy_move):
	Make copying iside the same directory while the
	GNOME_VFS_XFER_USE_UNIQUE_NAMES move_option is set legal.
parent 85697ce8
2001-01-31 Pavel Cisler <pavel@eazel.com>
reviewed by: Gene Z. Ragan <gzr@eazel.com>
Fix 5324 (Should get rid of stack-based GnomeVFSFileInfo)
* components/adapter/bonobo-stream-vfs.c: (vfs_get_info):
Nuked some unused code that contained gnome_vfs_file_info_init.
* components/adapter/nautilus-adapter-progressive-load-strategy.c:
(nautilus_adapter_progressive_load_strategy_load_location):
* libnautilus-extensions/nautilus-icon-factory.c:
(path_represents_svg_image), (get_cache_time):
* libnautilus-extensions/nautilus-thumbnails.c:
(first_file_more_recent):
* src/nautilus-window-menus.c: (get_static_bookmarks_file_path):
Get rid of gnome_vfs_file_info_init.
Replace all instances of stack-based GnomeVFSFileInfo
structures, replace all calls to gnome_vfs_file_info_init
with gnome_vfs_file_info_new.
Replace most calls to gnome_vfs_file_info_clear with
gnome_vfs_file_info_unref.
* libnautilus-extensions/nautilus-preferences-item.c:
(has_image_file):
Rework to use gnome_vfs_uri_exists instead of trying to get
file info.
* components/adapter/nautilus-adapter-progressive-load-strategy.c:
(nautilus_adapter_progressive_load_strategy_load_location):
Fixed a bug where file info fields were being used after a
gnome_vfs_file_info_clear call
Fix 6146 ("Duplicate File" reports "You cannot copy a file
over itself")
* libnautilus-extensions/nautilus-file-operations.c:
(nautilus_file_operations_copy_move):
Make copying iside the same directory while the
GNOME_VFS_XFER_USE_UNIQUE_NAMES move_option is set legal.
2001-01-31 Ian McKellar <ian@eazel.com>
reviewed by: Maciej Stachowiak <mjs@eazel.com>
......
......@@ -61,32 +61,6 @@ vfs_get_info (BonoboStream *stream,
g_warning ("BonoboStreamVFS:get_info not implemented");
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Stream_IOError, NULL);
/* The following code could be useful for as a start for
* writing get_info.
*/
#if 0
BonoboStreamVFS *stream_vfs;
GnomeVFSFileInfo file_info;
CORBA_long size;
stream_vfs = BONOBO_STREAM_VFS (stream);
gnome_vfs_file_info_init (&file_info);
if (gnome_vfs_get_file_info_from_handle (stream_vfs->details->handle,
&file_info,
GNOME_VFS_FILE_INFO_DEFAULT) != GNOME_VFS_OK) {
return 0;
}
/* FIXME bugzilla.eazel.com 4397: Will munge >31-bit file
* sizes, which can happen in gnome-vfs.
*/
size = file_info.size;
gnome_vfs_file_info_clear (&file_info);
return size;
#endif
return NULL;
}
......
......@@ -219,13 +219,14 @@ nautilus_adapter_progressive_load_strategy_load_location (NautilusAdapterLoadStr
const char *uri)
{
NautilusAdapterProgressiveLoadStrategy *strategy;
GnomeVFSFileInfo file_info;
GnomeVFSFileInfo *file_info;
GnomeVFSHandle *handle;
GnomeVFSResult result;
GnomeVFSFileSize bytes_read;
Bonobo_ProgressiveDataSink_iobuf *iobuf;
CORBA_octet *data;
CORBA_Environment ev;
GnomeVFSFileSize size;
strategy = NAUTILUS_ADAPTER_PROGRESSIVE_LOAD_STRATEGY (abstract_strategy);
......@@ -280,13 +281,17 @@ nautilus_adapter_progressive_load_strategy_load_location (NautilusAdapterLoadStr
CHECK_IF_STOPPED;
gnome_vfs_file_info_init (&file_info);
result = gnome_vfs_get_file_info_from_handle (handle, &file_info, GNOME_VFS_FILE_INFO_DEFAULT);
gnome_vfs_file_info_clear (&file_info);
file_info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info_from_handle (handle, file_info, GNOME_VFS_FILE_INFO_DEFAULT);
size = 0;
if (result == GNOME_VFS_OK && (file_info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_SIZE)) {
size = file_info->size;
}
gnome_vfs_file_info_unref (file_info);
if (result == GNOME_VFS_OK && file_info.valid_fields | GNOME_VFS_FILE_INFO_FIELDS_SIZE) {
if (size > 0) {
Bonobo_ProgressiveDataSink_setSize (strategy->details->progressive_data_sink,
(long) file_info.size, &ev);
(long) size, &ev);
CHECK_IF_STOPPED;
}
......
......@@ -1903,7 +1903,10 @@ nautilus_file_operations_copy_move (const GList *item_uris,
result = GNOME_VFS_ERROR_NOT_PERMITTED;
break;
}
if (gnome_vfs_uri_is_parent (target_dir_uri, uri, FALSE)) {
if (((move_options & GNOME_VFS_XFER_LINK_ITEMS) != 0
|| (move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0
|| (move_options & GNOME_VFS_XFER_USE_UNIQUE_NAMES) == 0)
&& gnome_vfs_uri_is_parent (target_dir_uri, uri, FALSE)) {
nautilus_run_simple_dialog
(parent_view,
FALSE,
......
......@@ -1628,7 +1628,7 @@ static gboolean
path_represents_svg_image (const char *path)
{
char *uri;
GnomeVFSFileInfo file_info;
GnomeVFSFileInfo *file_info;
gboolean is_svg;
/* Sync. file I/O is OK here because this is used only for installed
......@@ -1637,11 +1637,11 @@ path_represents_svg_image (const char *path)
*/
uri = gnome_vfs_get_uri_from_local_path (path);
gnome_vfs_file_info_init (&file_info);
gnome_vfs_get_file_info (uri, &file_info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
file_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (uri, file_info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
g_free (uri);
is_svg = nautilus_strcmp (file_info.mime_type, "image/svg") == 0;
gnome_vfs_file_info_clear (&file_info);
is_svg = nautilus_strcmp (file_info->mime_type, "image/svg") == 0;
gnome_vfs_file_info_unref (file_info);
return is_svg;
}
......@@ -1651,7 +1651,7 @@ static GnomeVFSResult
get_cache_time (const char *file_uri, time_t *cache_time)
{
GnomeVFSURI *vfs_uri;
GnomeVFSFileInfo file_info;
GnomeVFSFileInfo *file_info;
GnomeVFSResult result;
gboolean is_local;
......@@ -1671,12 +1671,12 @@ get_cache_time (const char *file_uri, time_t *cache_time)
}
/* Gather the info and then compare modification times. */
gnome_vfs_file_info_init (&file_info);
result = gnome_vfs_get_file_info (file_uri, &file_info, GNOME_VFS_FILE_INFO_DEFAULT);
file_info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (file_uri, file_info, GNOME_VFS_FILE_INFO_DEFAULT);
if (result == GNOME_VFS_OK) {
*cache_time = file_info.mtime;
*cache_time = file_info->mtime;
}
gnome_vfs_file_info_clear (&file_info);
gnome_vfs_file_info_unref (file_info);
return result;
}
......
......@@ -542,32 +542,30 @@ static const char *icon_file_name_suffixes[] =
static gboolean
has_image_file(const char *directory_uri, const char *dir_name, const char *required_file)
{
char *temp_str, *base_uri;
char *temp_str, *base_uri_string;
guint index;
GnomeVFSResult result;
GnomeVFSFileInfo *file_info;
file_info = gnome_vfs_file_info_new ();
gboolean result;
GnomeVFSURI *base_uri, *uri;
temp_str = nautilus_make_path(directory_uri, dir_name);
base_uri = nautilus_make_path(temp_str, required_file);
g_free(temp_str);
temp_str = nautilus_make_path (directory_uri, dir_name);
base_uri_string = nautilus_make_path (temp_str, required_file);
base_uri = gnome_vfs_uri_new (base_uri_string);
g_free (temp_str);
g_free (base_uri_string);
result = FALSE;
for (index = 0; index < NAUTILUS_N_ELEMENTS (icon_file_name_suffixes); index++) {
temp_str = g_strconcat (base_uri, icon_file_name_suffixes[index], NULL);
gnome_vfs_file_info_init (file_info);
result = gnome_vfs_get_file_info (temp_str, file_info, 0);
g_free(temp_str);
if (result == GNOME_VFS_OK) {
g_free(base_uri);
gnome_vfs_file_info_unref (file_info);
return TRUE;
}
uri = gnome_vfs_uri_append_string (base_uri, icon_file_name_suffixes[index]);
result = gnome_vfs_uri_exists (uri);
gnome_vfs_uri_unref (uri);
if (result) {
break;
}
}
gnome_vfs_file_info_unref (file_info);
g_free(base_uri);
return FALSE;
gnome_vfs_uri_unref (base_uri);
g_free (base_uri);
return result;
}
/* add available icon themes to the theme list by iterating through the
......
......@@ -170,7 +170,7 @@ first_file_more_recent(const char* file_uri, const char* other_file_uri)
GnomeVFSURI *vfs_uri, *other_vfs_uri;
gboolean more_recent, is_local;
GnomeVFSFileInfo file_info, other_file_info;
GnomeVFSFileInfo *file_info, *other_file_info;
/* if either file is remote, return FALSE. Eventually we'll make this async to fix this */
vfs_uri = gnome_vfs_uri_new(file_uri);
......@@ -184,16 +184,16 @@ first_file_more_recent(const char* file_uri, const char* other_file_uri)
}
/* gather the info and then compare modification times */
gnome_vfs_file_info_init (&file_info);
gnome_vfs_get_file_info (file_uri, &file_info, GNOME_VFS_FILE_INFO_DEFAULT);
file_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (file_uri, file_info, GNOME_VFS_FILE_INFO_DEFAULT);
gnome_vfs_file_info_init (&other_file_info);
gnome_vfs_get_file_info (other_file_uri, &other_file_info, GNOME_VFS_FILE_INFO_DEFAULT);
other_file_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (other_file_uri, other_file_info, GNOME_VFS_FILE_INFO_DEFAULT);
more_recent = file_info.mtime > other_file_info.mtime;
more_recent = file_info->mtime > other_file_info->mtime;
gnome_vfs_file_info_clear (&file_info);
gnome_vfs_file_info_clear (&other_file_info);
gnome_vfs_file_info_unref (file_info);
gnome_vfs_file_info_unref (other_file_info);
return more_recent;
}
......
......@@ -1903,7 +1903,10 @@ nautilus_file_operations_copy_move (const GList *item_uris,
result = GNOME_VFS_ERROR_NOT_PERMITTED;
break;
}
if (gnome_vfs_uri_is_parent (target_dir_uri, uri, FALSE)) {
if (((move_options & GNOME_VFS_XFER_LINK_ITEMS) != 0
|| (move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0
|| (move_options & GNOME_VFS_XFER_USE_UNIQUE_NAMES) == 0)
&& gnome_vfs_uri_is_parent (target_dir_uri, uri, FALSE)) {
nautilus_run_simple_dialog
(parent_view,
FALSE,
......
......@@ -1628,7 +1628,7 @@ static gboolean
path_represents_svg_image (const char *path)
{
char *uri;
GnomeVFSFileInfo file_info;
GnomeVFSFileInfo *file_info;
gboolean is_svg;
/* Sync. file I/O is OK here because this is used only for installed
......@@ -1637,11 +1637,11 @@ path_represents_svg_image (const char *path)
*/
uri = gnome_vfs_get_uri_from_local_path (path);
gnome_vfs_file_info_init (&file_info);
gnome_vfs_get_file_info (uri, &file_info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
file_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (uri, file_info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
g_free (uri);
is_svg = nautilus_strcmp (file_info.mime_type, "image/svg") == 0;
gnome_vfs_file_info_clear (&file_info);
is_svg = nautilus_strcmp (file_info->mime_type, "image/svg") == 0;
gnome_vfs_file_info_unref (file_info);
return is_svg;
}
......@@ -1651,7 +1651,7 @@ static GnomeVFSResult
get_cache_time (const char *file_uri, time_t *cache_time)
{
GnomeVFSURI *vfs_uri;
GnomeVFSFileInfo file_info;
GnomeVFSFileInfo *file_info;
GnomeVFSResult result;
gboolean is_local;
......@@ -1671,12 +1671,12 @@ get_cache_time (const char *file_uri, time_t *cache_time)
}
/* Gather the info and then compare modification times. */
gnome_vfs_file_info_init (&file_info);
result = gnome_vfs_get_file_info (file_uri, &file_info, GNOME_VFS_FILE_INFO_DEFAULT);
file_info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (file_uri, file_info, GNOME_VFS_FILE_INFO_DEFAULT);
if (result == GNOME_VFS_OK) {
*cache_time = file_info.mtime;
*cache_time = file_info->mtime;
}
gnome_vfs_file_info_clear (&file_info);
gnome_vfs_file_info_unref (file_info);
return result;
}
......
......@@ -542,32 +542,30 @@ static const char *icon_file_name_suffixes[] =
static gboolean
has_image_file(const char *directory_uri, const char *dir_name, const char *required_file)
{
char *temp_str, *base_uri;
char *temp_str, *base_uri_string;
guint index;
GnomeVFSResult result;
GnomeVFSFileInfo *file_info;
file_info = gnome_vfs_file_info_new ();
gboolean result;
GnomeVFSURI *base_uri, *uri;
temp_str = nautilus_make_path(directory_uri, dir_name);
base_uri = nautilus_make_path(temp_str, required_file);
g_free(temp_str);
temp_str = nautilus_make_path (directory_uri, dir_name);
base_uri_string = nautilus_make_path (temp_str, required_file);
base_uri = gnome_vfs_uri_new (base_uri_string);
g_free (temp_str);
g_free (base_uri_string);
result = FALSE;
for (index = 0; index < NAUTILUS_N_ELEMENTS (icon_file_name_suffixes); index++) {
temp_str = g_strconcat (base_uri, icon_file_name_suffixes[index], NULL);
gnome_vfs_file_info_init (file_info);
result = gnome_vfs_get_file_info (temp_str, file_info, 0);
g_free(temp_str);
if (result == GNOME_VFS_OK) {
g_free(base_uri);
gnome_vfs_file_info_unref (file_info);
return TRUE;
}
uri = gnome_vfs_uri_append_string (base_uri, icon_file_name_suffixes[index]);
result = gnome_vfs_uri_exists (uri);
gnome_vfs_uri_unref (uri);
if (result) {
break;
}
}
gnome_vfs_file_info_unref (file_info);
g_free(base_uri);
return FALSE;
gnome_vfs_uri_unref (base_uri);
g_free (base_uri);
return result;
}
/* add available icon themes to the theme list by iterating through the
......
......@@ -170,7 +170,7 @@ first_file_more_recent(const char* file_uri, const char* other_file_uri)
GnomeVFSURI *vfs_uri, *other_vfs_uri;
gboolean more_recent, is_local;
GnomeVFSFileInfo file_info, other_file_info;
GnomeVFSFileInfo *file_info, *other_file_info;
/* if either file is remote, return FALSE. Eventually we'll make this async to fix this */
vfs_uri = gnome_vfs_uri_new(file_uri);
......@@ -184,16 +184,16 @@ first_file_more_recent(const char* file_uri, const char* other_file_uri)
}
/* gather the info and then compare modification times */
gnome_vfs_file_info_init (&file_info);
gnome_vfs_get_file_info (file_uri, &file_info, GNOME_VFS_FILE_INFO_DEFAULT);
file_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (file_uri, file_info, GNOME_VFS_FILE_INFO_DEFAULT);
gnome_vfs_file_info_init (&other_file_info);
gnome_vfs_get_file_info (other_file_uri, &other_file_info, GNOME_VFS_FILE_INFO_DEFAULT);
other_file_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (other_file_uri, other_file_info, GNOME_VFS_FILE_INFO_DEFAULT);
more_recent = file_info.mtime > other_file_info.mtime;
more_recent = file_info->mtime > other_file_info->mtime;
gnome_vfs_file_info_clear (&file_info);
gnome_vfs_file_info_clear (&other_file_info);
gnome_vfs_file_info_unref (file_info);
gnome_vfs_file_info_unref (other_file_info);
return more_recent;
}
......
......@@ -819,7 +819,8 @@ get_static_bookmarks_file_path (void)
char *update_uri, *built_in_uri;
char *user_directory_path;
gboolean update_exists, built_in_exists;
GnomeVFSFileInfo update_info, built_in_info;
GnomeVFSFileInfo *update_info, *built_in_info;
char *result;
/* see if there is a static bookmarks file in the updates directory and get its mod-date */
user_directory_path = nautilus_get_user_directory ();
......@@ -851,23 +852,28 @@ get_static_bookmarks_file_path (void)
/* both files exist, so use the one with the most recent mod-date */
update_uri = gnome_vfs_get_local_path_from_uri (update_xml_file_path);
gnome_vfs_file_info_init (&update_info);
gnome_vfs_get_file_info (update_uri, &update_info, GNOME_VFS_FILE_INFO_DEFAULT);
update_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (update_uri, update_info, GNOME_VFS_FILE_INFO_DEFAULT);
g_free (update_uri);
built_in_uri = gnome_vfs_get_local_path_from_uri (built_in_xml_file_path);
gnome_vfs_file_info_init (&built_in_info);
gnome_vfs_get_file_info (built_in_uri, &built_in_info, GNOME_VFS_FILE_INFO_DEFAULT);
built_in_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (built_in_uri, built_in_info, GNOME_VFS_FILE_INFO_DEFAULT);
g_free (built_in_uri);
/* see which is most recent */
if (update_info.mtime > built_in_info.mtime) {
if (update_info->mtime <= built_in_info->mtime) {
result = built_in_xml_file_path;
g_free (update_xml_file_path);
} else {
result = update_xml_file_path;
g_free (built_in_xml_file_path);
return update_xml_file_path;
}
g_free (update_xml_file_path);
return built_in_xml_file_path;
}
gnome_vfs_file_info_unref (update_info);
gnome_vfs_file_info_unref (built_in_info);
return result;
}
static void
......
......@@ -819,7 +819,8 @@ get_static_bookmarks_file_path (void)
char *update_uri, *built_in_uri;
char *user_directory_path;
gboolean update_exists, built_in_exists;
GnomeVFSFileInfo update_info, built_in_info;
GnomeVFSFileInfo *update_info, *built_in_info;
char *result;
/* see if there is a static bookmarks file in the updates directory and get its mod-date */
user_directory_path = nautilus_get_user_directory ();
......@@ -851,23 +852,28 @@ get_static_bookmarks_file_path (void)
/* both files exist, so use the one with the most recent mod-date */
update_uri = gnome_vfs_get_local_path_from_uri (update_xml_file_path);
gnome_vfs_file_info_init (&update_info);
gnome_vfs_get_file_info (update_uri, &update_info, GNOME_VFS_FILE_INFO_DEFAULT);
update_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (update_uri, update_info, GNOME_VFS_FILE_INFO_DEFAULT);
g_free (update_uri);
built_in_uri = gnome_vfs_get_local_path_from_uri (built_in_xml_file_path);
gnome_vfs_file_info_init (&built_in_info);
gnome_vfs_get_file_info (built_in_uri, &built_in_info, GNOME_VFS_FILE_INFO_DEFAULT);
built_in_info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (built_in_uri, built_in_info, GNOME_VFS_FILE_INFO_DEFAULT);
g_free (built_in_uri);
/* see which is most recent */
if (update_info.mtime > built_in_info.mtime) {
if (update_info->mtime <= built_in_info->mtime) {
result = built_in_xml_file_path;
g_free (update_xml_file_path);
} else {
result = update_xml_file_path;
g_free (built_in_xml_file_path);
return update_xml_file_path;
}
g_free (update_xml_file_path);
return built_in_xml_file_path;
}
gnome_vfs_file_info_unref (update_info);
gnome_vfs_file_info_unref (built_in_info);
return result;
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment