[patch #4162] detach on quick-save

2006-03-17 Thread Oswald Buddenhagen

Follow-up Comment #2, patch #4162 (project mc):

you put the mc_close() outside an else branch; you'll now close an arbitrary
handle if the file is not local; closing -1 is not too nice, either.
other than that it looks ok.

btw, edit_save_as_cmd() uses mc_open() to fake an mc_stat() - i think it
would make sense to change it.


___

Reply to this item at:

  http://savannah.gnu.org/patch/?func=detailitemitem_id=4162

___
  Message sent via/by Savannah
  http://savannah.gnu.org/

___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


[patch #4162] detach on quick-save

2006-03-17 Thread Pavel Tsekov

Follow-up Comment #3, patch #4162 (project mc):

Right! My bad. The logic was pretty twisted anyway. I'll fix the patch and
commit it.

I also noted that mc_open() is used to emulate stat() on at least one more
place but I didn't want to change it since I might miss something .



___

Reply to this item at:

  http://savannah.gnu.org/patch/?func=detailitemitem_id=4162

___
  Message sent via/by Savannah
  http://savannah.gnu.org/

___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


[patch #4162] detach on quick-save

2006-03-17 Thread Pavel Tsekov

Update of patch #4162 (project mc):

  Status: In Progress = Done   
 Open/Closed:Open = Closed 

___

Follow-up Comment #4:

I've commited the patch.

Thanks!


___

Reply to this item at:

  http://savannah.gnu.org/patch/?func=detailitemitem_id=4162

___
  Message sent via/by Savannah
  http://savannah.gnu.org/

___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


detach on quick-save

2005-02-07 Thread Oswald Buddenhagen
moin,

in quick-save mode the editor just overwrites the existing file. this is
all fine ... except when you cloned a source tree with cp -al and want
to patch one copy.
this patch adds a check whether the file has multiple hard links and
asks whether the file should be detached before saving.
not sure the dialog looks 100% right, but you get the idea. :)

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
Index: edit/edit-widget.h
===
RCS file: /cvsroot/mc/mc/edit/edit-widget.h,v
retrieving revision 1.24
diff -U2 -r1.24 edit-widget.h
--- edit/edit-widget.h  3 Dec 2004 17:09:27 -   1.24
+++ edit/edit-widget.h  7 Feb 2005 17:32:40 -
@@ -90,4 +90,5 @@
 
 struct stat stat1; /* Result of mc_fstat() on the file */
+int skip_ask_if_detach:1;  /* Already asked whether to detach file */
 
 /* syntax higlighting */
Index: edit/editcmd.c
===
RCS file: /cvsroot/mc/mc/edit/editcmd.c,v
retrieving revision 1.128
diff -U2 -r1.128 editcmd.c
--- edit/editcmd.c  7 Feb 2005 07:31:19 -   1.128
+++ edit/editcmd.c  7 Feb 2005 17:32:41 -
@@ -262,6 +262,23 @@
savename = g_strdup (filename);
 
-mc_chown (savename, edit-stat1.st_uid, edit-stat1.st_gid);
-mc_chmod (savename, edit-stat1.st_mode);
+if (this_save_mode == EDIT_QUICK_SAVE 
+   edit-stat1.st_nlink  1 
+   !edit-skip_ask_if_detach)
+{
+   switch (query_dialog (_( File has hard-links ),
+ _(Detach before saving?), 0,
+ 3, _(Yes), _(No), _(Cancel)))
+   {
+   case 0:
+   mc_unlink (savename);
+   /* fallthrough */
+   case 1:
+   edit-skip_ask_if_detach = 1;
+   break;
+   default:
+   g_free (savename);
+   return 1;
+   }
+}
 
 if ((fd =
@@ -270,4 +287,7 @@
goto error_save;
 
+mc_chown (savename, edit-stat1.st_uid, edit-stat1.st_gid);
+mc_chmod (savename, edit-stat1.st_mode);
+
 /* pipe save */
 if ((p = edit_get_write_filter (savename, filename))) {
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel