Commit 11df3df6 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson
Browse files

Migration of old .gnome-desktop.

2003-05-16  Alexander Larsson  <alexl@redhat.com>

	* src/nautilus-application.c (migrate_old_nautilus_files):
	Migration of old .gnome-desktop.
parent 4c8586bb
2003-05-16 Alexander Larsson <alexl@redhat.com>
* src/nautilus-application.c (migrate_old_nautilus_files):
Migration of old .gnome-desktop.
2003-05-16 Padraig O'Briain <padraig.obriain@sun.com> 2003-05-16 Padraig O'Briain <padraig.obriain@sun.com>
* src/file-manager/fm-list-view.c: * src/file-manager/fm-list-view.c:
......
...@@ -28,10 +28,14 @@ ...@@ -28,10 +28,14 @@
#include <config.h> #include <config.h>
#include "nautilus-application.h" #include "nautilus-application.h"
#include "file-manager/fm-desktop-icon-view.h" #include "file-manager/fm-desktop-icon-view.h"
#include "file-manager/fm-icon-view.h" #include "file-manager/fm-icon-view.h"
#include "file-manager/fm-list-view.h" #include "file-manager/fm-list-view.h"
#include "file-manager/fm-search-list-view.h" #include "file-manager/fm-search-list-view.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "nautilus-desktop-window.h" #include "nautilus-desktop-window.h"
#include "nautilus-first-time-druid.h" #include "nautilus-first-time-druid.h"
#include "nautilus-main.h" #include "nautilus-main.h"
...@@ -39,7 +43,6 @@ ...@@ -39,7 +43,6 @@
#include "nautilus-shell.h" #include "nautilus-shell.h"
#include <bonobo/bonobo-main.h> #include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-object.h> #include <bonobo/bonobo-object.h>
#include <dirent.h>
#include <eel/eel-gtk-macros.h> #include <eel/eel-gtk-macros.h>
#include <eel/eel-stock-dialogs.h> #include <eel/eel-stock-dialogs.h>
#include <eel/eel-string-list.h> #include <eel/eel-string-list.h>
...@@ -280,56 +283,43 @@ nautilus_make_uri_list_from_shell_strv (const char * const *strv) ...@@ -280,56 +283,43 @@ nautilus_make_uri_list_from_shell_strv (const char * const *strv)
static void static void
migrate_old_nautilus_files (void) migrate_old_nautilus_files (void)
{ {
char *new_desktop_dir, *np; char *new_desktop_dir;
char *old_desktop_dir, *op; char *old_desktop_dir;
char *old_desktop_dir_new_name; char *migrated_file;
struct stat buf; char *link_name;
DIR *dir; char *link_path;
struct dirent *de; int fd;
old_desktop_dir = g_strconcat (g_get_home_dir (), "/.nautilus/desktop", NULL); old_desktop_dir = nautilus_get_gmc_desktop_directory ();
if (stat (old_desktop_dir, &buf) == -1) { if (!g_file_test (old_desktop_dir, G_FILE_TEST_IS_DIR)) {
g_free (old_desktop_dir); g_free (old_desktop_dir);
return; return;
} }
if (!S_ISLNK (buf.st_mode)){ migrated_file = g_build_filename (old_desktop_dir, ".migrated", NULL);
dir = opendir (old_desktop_dir); if (!g_file_test (migrated_file, G_FILE_TEST_EXISTS)) {
if (dir == NULL) { link_name = g_filename_from_utf8 (_("Link To Old Desktop"), -1, NULL, NULL, NULL);
g_free (old_desktop_dir);
return;
}
new_desktop_dir = nautilus_get_desktop_directory (); new_desktop_dir = nautilus_get_desktop_directory ();
link_path = g_build_filename (new_desktop_dir, link_name, NULL);
while ((de = readdir (dir)) != NULL){
if (de->d_name [0] == '.'){
if (de->d_name [0] == 0)
continue;
if (de->d_name [1] == '.' && de->d_name [2] == 0)
continue;
}
op = g_strconcat (old_desktop_dir, "/", de->d_name, NULL);
np = g_strconcat (new_desktop_dir, "/", de->d_name, NULL); symlink ("../.gnome-desktop", link_path);
rename (op, np); g_free (link_name);
g_free (op);
g_free (np);
}
closedir (dir);
g_free (new_desktop_dir); g_free (new_desktop_dir);
} g_free (link_path);
/* In case we miss something */ fd = creat (migrated_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
old_desktop_dir_new_name = g_strconcat (old_desktop_dir, "-old", NULL); if (fd >= 0) {
rename (old_desktop_dir, old_desktop_dir_new_name); close (fd);
g_free (old_desktop_dir_new_name); }
g_free (old_desktop_dir); eel_show_info_dialog (_("The location of the desktop directory has changed in Gnome 2.4. "
"A link called \"Link To Old Desktop\" has been created on the desktop. "
"You can open this to move over the files you want, then delete the link."),
_("Migrated old desktop"),
NULL);
}
g_free (migrated_file);
} }
static gint static gint
......
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