xffm changes

Jens Luedicke jens at irs-net.com
Mon Jan 27 14:59:12 CET 2003


On Mon, Jan 27, 2003 at 06:54:44AM -0600, edscott wilson garcia wrote:

> > I attached a patch of my new old changes. They include the backup
> > feature. I tested them and they work for me.
> 
> If you use xfdiff to create your patch files (or create them in unified
> format), I could actually use xfdiff to see what changes are implied,
> line by line. The way you are sending them makes it more difficult to
> read and I need more time to do so
> 

I recreated and attached the patch using 'cvs diff -u remove.c > ...'


-- 
Jens Luedicke <jens at irs-net.com>

"Never offend people with style when you can offend them with substance."
--Sam Brown

-------------- next part --------------
Index: remove.c
===================================================================
RCS file: /cvsroot/xfce/xfce-devel/xffm/src/remove.c,v
retrieving revision 1.14
diff -u -r1.14 remove.c
--- remove.c	27 Jan 2003 03:40:45 -0000	1.14
+++ remove.c	27 Jan 2003 13:54:53 -0000
@@ -144,32 +144,59 @@
 }
 
 
-gboolean wasteit(char *path){
-	char *directory=g_strdup(path);
-	char wastepath[256];
-	char wastename[256];
-	if (!strchr(path,'/')) g_assert_not_reached();
-	if (strlen(path)==1) return FALSE;
-	*(strrchr(directory,'/'))=0;
-	sprintf(wastepath,"%s/..Wastebasket",directory);
-	g_free(directory);
-	/*printf("DBG:wastepath=%s\n",wastepath);*/
-	if (access(wastepath,F_OK) != 0){
-		if (mkdir (wastepath, 0xFFFF) < 0) return FALSE;
-		
-	}
-	sprintf(wastename,"%s/%s",wastepath,strrchr(path,'/')+1);
-	/*printf("DBG:wastename=%s path=%s\n",wastename,path);*/
-	if (access(wastename,F_OK) == 0) {
-	   /* too harsh: if (!unlinkit(wastename)) return FALSE;*/
-	   char wastebackup[256];
-	   sprintf(wastebackup,"%s/%s",
-		wastepath,new_name(wastepath,strrchr(wastename,'/')+1));
-	   /*printf("DBG:wastebackup=%s\n",wastebackup);*/
-	   if (rename(wastename,wastebackup)<0) return FALSE;
-	}
-	if (rename(path,wastename)<0) return FALSE;
-	return TRUE;
+gboolean
+wasteit (char *path)
+{
+  gchar *filepath = NULL;
+  gchar *filename = NULL;
+  gchar *wastepath = NULL;
+  gchar *wastename = NULL;
+  gchar *wastebackup = NULL;
+
+  if (!strchr (path, '/'))
+    g_assert_not_reached ();
+
+  if (strlen (path) == 1)
+    return FALSE;
+
+  filepath = g_path_get_dirname (path);
+  filename = g_path_get_basename (path);
+
+  wastepath = g_strconcat (filepath, "/..Wastebasket/", NULL);
+  wastename = g_strconcat (wastepath, filename, NULL);
+
+  /*
+     printf("DBG:wastepath=%s\n",wastepath);
+     printf("DBG:wastename=%s path=%s\n",wastename,path);
+   */
+
+  if (access (wastepath, F_OK) != 0)
+    {
+      if (mkdir (wastepath, 0xFFFF) < 0)
+	return FALSE;
+    }
+
+  if (access(wastename,F_OK) == 0) {
+	/* too harsh: if (!unlinkit(wastename)) return FALSE;*/
+	wastebackup = g_strconcat(wastepath, new_name(wastepath, filename));
+	/*
+	printf("DBG:wastebackup=%s\n",wastebackup);
+	*/
+
+	if (rename(wastename,wastebackup)<0)
+	    return FALSE;
+  }
+
+  if (rename (path, wastename) < 0)
+    return FALSE;
+
+  g_free (filepath);
+  g_free (filename);
+  g_free (wastepath);
+  g_free (wastename);
+  g_free (wastebackup);
+
+  return TRUE;
 }
 
 


More information about the Xfce4-dev mailing list