Esempio n. 1
0
/**
 * gva_audit_detect_changes:
 *
 * Attempts to detect ROM and sample file changes since the last program
 * execution by scanning the timestamps on the directories listed in the
 * "rompath" and "samplepath" configuration values.  It returns %TRUE if
 * any of those timestamps are more recent than the game database.
 *
 * Returns: %TRUE if changes were detected
 **/
gboolean
gva_audit_detect_changes (void)
{
        gboolean changes = FALSE;
        gchar **directories;
        struct stat st;
        guint length, ii;
        GError *error = NULL;

        if (g_stat (gva_db_get_filename (), &st) < 0)
                return FALSE;

        directories = gva_mame_get_search_paths ("rompath", &error);
        length = (directories != NULL) ? g_strv_length (directories) : 0;
        gva_error_handle (&error);

        for (ii = 0; ii < length; ii++)
                changes |= gva_db_is_older_than (directories[ii]);

        g_strfreev (directories);

        directories = gva_mame_get_search_paths ("samplepath", &error);
        length = (directories != NULL) ? g_strv_length (directories) : 0;
        gva_error_handle (&error);

        for (ii = 0; ii < length; ii++)
                changes |= gva_db_is_older_than (directories[ii]);

        g_strfreev (directories);

        return changes;
}
Esempio n. 2
0
static gboolean
setup_file_monitors (void)
{
        gchar **search_paths;
        guint length, ii;

        /* We don't care about errors while setting up file monitors
         * since it's just a "nice to have" feature. */

        search_paths = gva_mame_get_search_paths ("rompath", NULL);
        length = (search_paths != NULL) ? g_strv_length (search_paths) : 0;

        for (ii = 0; ii < length; ii++)
        {
                GFileMonitor *monitor;
                GFile *file;

                /* Skip paths that don't exist or are not directories. */
                if (!g_file_test (search_paths[ii], G_FILE_TEST_IS_DIR))
                        continue;

                file = g_file_new_for_path (search_paths[ii]);
                monitor = g_file_monitor (file, 0, NULL, NULL);
                g_object_unref (file);

                if (monitor == NULL)
                        continue;

                g_signal_connect (
                        monitor, "changed",
                        G_CALLBACK (rompath_changed_cb), NULL);

                /* We leak the file monitor reference, but the
                 * monitor lives for the entire session anyway. */
        }

        g_strfreev (search_paths);

        return FALSE;
}