SF.net SVN: geany: [1074] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sat Dec 9 13:07:24 UTC 2006


Revision: 1074
          http://svn.sourceforge.net/geany/?rev=1074&view=rev
Author:   ntrel
Date:     2006-12-09 05:07:23 -0800 (Sat, 09 Dec 2006)

Log Message:
-----------
Read the file's modification timestamp after saving because on
Windows it can be later than expected (closes #1611530).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-12-09 13:06:50 UTC (rev 1073)
+++ trunk/ChangeLog	2006-12-09 13:07:23 UTC (rev 1074)
@@ -1,3 +1,12 @@
+2006-12-09  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/build.c:
+   Fix building on win32; also fix some warnings.
+ * src/document.c:
+   Read the file's modification timestamp after saving because on
+   Windows it can be later than expected (closes #1611530).
+
+
 2006-12-08  Nick Treleaven  <nick.treleaven at btinternet.com>
 
  * src/build.c, src/interface.c, src/ui_utils.h, src/build.h,
@@ -14,8 +23,6 @@
    removes empty menus.
  * src/dialogs.c, src/ui_utils.c:
    Use ui_button_new_with_image() in dialogs_show_unsaved_file().
-   Improved auto completion of multi line comments and support
-   /+ +/ for D files.
 
 
 2006-12-08  Enrico Troeger  <enrico.troeger at uvena.de>
@@ -30,6 +37,9 @@
  * src/msgwindow.c: Removed compiler warning.
  * src/sci_cb.c, src/sci_cb.h:
    Made sci_cb_get_indent and sci_Cb_auto_multiline static.
+ * src/sci_cb.c, src/sci_cb.h:
+   Improved auto completion of multi line comments and support
+   /+ +/ for D files.
  * src/msgwindow.c: Fixed wrong check button state in view menu if
                     message window was shown automatically.
 

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-12-09 13:06:50 UTC (rev 1073)
+++ trunk/src/document.c	2006-12-09 13:07:23 UTC (rev 1074)
@@ -782,6 +782,29 @@
 }
 
 
+static gboolean document_update_timestamp(gint idx)
+{
+	struct stat st;
+	gchar *locale_filename;
+	
+	g_return_val_if_fail(DOC_IDX_VALID(idx), FALSE);
+
+	locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
+
+	if (stat(locale_filename, &st) != 0)
+	{
+		msgwin_status_add(_("Could not open file %s (%s)"), doc_list[idx].file_name,
+			g_strerror(errno));
+		g_free(locale_filename);
+		return FALSE;
+	}
+
+	doc_list[idx].mtime = st.st_mtime; // get the modification time from file and keep it
+	g_free(locale_filename);
+	return TRUE;
+}
+
+
 /* This saves the file.
  * When force is set then it is always saved, even if it is unchanged(useful when using Save As)
  * It returns whether the file could be saved or not. */
@@ -896,7 +919,11 @@
 		// there are more lines than before
 		sci_set_line_numbers(doc_list[idx].sci, app->show_linenumber_margin, 0);
 		sci_set_savepoint(doc_list[idx].sci);
-		doc_list[idx].mtime = time(NULL);
+
+		/* stat the file to get the timestamp, otherwise on Windows the actual
+		 * timestamp can be ahead of time(NULL) */
+		document_update_timestamp(idx);
+
 		if (doc_list[idx].file_type == NULL || doc_list[idx].file_type->id == GEANY_FILETYPES_ALL)
 		{
 			doc_list[idx].file_type = filetypes_get_from_filename(idx);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list