mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Last modified file text missing for files like Comité.gnucash on Windows
This is down to the use of stat so changed to use GFile to get the last modified date.
This commit is contained in:
parent
43c2b7e9d7
commit
a9dcf0d81d
@ -1737,40 +1737,41 @@ static gchar *generate_statusbar_lastmodified_message()
|
||||
{
|
||||
if (gnc_uri_targets_local_fs (uri))
|
||||
{
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
/* The filename is a true file. */
|
||||
gchar *filepath = gnc_uri_get_path ( uri );
|
||||
gchar *filename = g_path_get_basename ( filepath );
|
||||
GFile *file = g_file_new_for_uri (uri);
|
||||
GFileInfo *info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
NULL, NULL);
|
||||
|
||||
if (info && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
|
||||
{
|
||||
// Access the mtime information through stat(2)
|
||||
struct stat statbuf;
|
||||
int r = stat(filepath, &statbuf);
|
||||
if (r == 0)
|
||||
{
|
||||
/* Translators: This is the date and time that is shown in
|
||||
the status bar after opening a file: The date and time of
|
||||
last modification. The string is a format string using
|
||||
boost::date_time's format flags, see the boost docs for an
|
||||
explanation of the modifiers. */
|
||||
char *time_string = gnc_print_time64(statbuf.st_mtime,
|
||||
_("Last modified on %a, %b %d, %Y at %I:%M %p"));
|
||||
//g_warning("got time %ld, str=%s\n", mtime, time_string);
|
||||
/* Translators: This message appears in the status bar after opening the file. */
|
||||
message = g_strdup_printf(_("File %s opened. %s"),
|
||||
filename, time_string);
|
||||
free(time_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning("Unable to read mtime for file %s\n", filepath);
|
||||
// message is still NULL
|
||||
}
|
||||
guint64 modtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||
|
||||
/* Translators: This is the date and time that is shown in
|
||||
the status bar after opening a file: The date and time of
|
||||
last modification. The string is a format string using
|
||||
boost::date_time's format flags, see the boost docs for an
|
||||
explanation of the modifiers. */
|
||||
char *time_string = gnc_print_time64 (modtime,
|
||||
_("Last modified on %a, %b %d, %Y at %I:%M %p"));
|
||||
//g_warning("got time %ld, str=%s\n", mtime, time_string);
|
||||
/* Translators: This message appears in the status bar after opening the file. */
|
||||
message = g_strdup_printf(_("File %s opened. %s"),
|
||||
filename, time_string);
|
||||
free(time_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning("Unable to read mtime for file %s\n", filepath);
|
||||
// message is still NULL
|
||||
}
|
||||
g_free(filename);
|
||||
g_free(filepath);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
g_object_unref (info);
|
||||
g_object_unref (file);
|
||||
}
|
||||
// If the URI is not a file but a database, we can maybe also show
|
||||
// something useful, but I have no idea how to obtain this information.
|
||||
|
Loading…
Reference in New Issue
Block a user