diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2020-09-21 17:35:06 +0200 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2020-09-21 17:55:41 +0200 |
commit | 910409a53cd4e6fa03ba97d4c10b404a0bbaeacb (patch) | |
tree | a8c56a11ffd36c0f4dc37584609338c6694ce978 | |
parent | a39b3ae720cbe4984be457a0f3edb0332d82da28 (diff) | |
download | tracker-sam/common-file-utils.tar.gz |
Move file-utils from libtracker-common into libtracker-datasam/common-file-utils
We only use these in one place, so we can move them there.
This should fix https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/140
in which the file-utils symbols conflict with those defined in
libtracker-miners-common.
The unit tests are gone, I'm not sure how to avoid that since we need
to avoid exporting these functions.
-rw-r--r-- | src/libtracker-common/meson.build | 1 | ||||
-rw-r--r-- | src/libtracker-common/tracker-common.h | 1 | ||||
-rw-r--r-- | src/libtracker-data/meson.build | 1 | ||||
-rw-r--r-- | src/libtracker-data/tracker-db-manager.c | 1 | ||||
-rw-r--r-- | src/libtracker-data/tracker-file-utils.c (renamed from src/libtracker-common/tracker-file-utils.c) | 0 | ||||
-rw-r--r-- | src/libtracker-data/tracker-file-utils.h (renamed from src/libtracker-common/tracker-file-utils.h) | 0 | ||||
-rw-r--r-- | tests/libtracker-common/meson.build | 1 | ||||
-rw-r--r-- | tests/libtracker-common/tracker-file-utils-test.c | 104 | ||||
-rw-r--r-- | tests/libtracker-common/tracker-utils-test.c | 1 |
9 files changed, 2 insertions, 108 deletions
diff --git a/src/libtracker-common/meson.build b/src/libtracker-common/meson.build index aff153637..716cc5056 100644 --- a/src/libtracker-common/meson.build +++ b/src/libtracker-common/meson.build @@ -13,7 +13,6 @@ tracker_common_enum_header = enums[1] tracker_common_sources = [ 'tracker-date-time.c', 'tracker-debug.c', - 'tracker-file-utils.c', 'tracker-term-utils.c', 'tracker-utils.c', 'tracker-locale.c', diff --git a/src/libtracker-common/tracker-common.h b/src/libtracker-common/tracker-common.h index 5bc03c9bf..b826f9aad 100644 --- a/src/libtracker-common/tracker-common.h +++ b/src/libtracker-common/tracker-common.h @@ -30,7 +30,6 @@ #include "tracker-date-time.h" #include "tracker-debug.h" -#include "tracker-file-utils.h" #include "tracker-language.h" #include "tracker-parser.h" #include "tracker-term-utils.h" diff --git a/src/libtracker-data/meson.build b/src/libtracker-data/meson.build index b367edd12..5c1a8cfb5 100644 --- a/src/libtracker-data/meson.build +++ b/src/libtracker-data/meson.build @@ -20,6 +20,7 @@ libtracker_data = static_library('tracker-data', 'tracker-db-interface.c', 'tracker-db-interface-sqlite.c', 'tracker-db-manager.c', + 'tracker-file-utils.c', 'tracker-namespace.c', 'tracker-ontology.c', 'tracker-ontologies.c', diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c index 4eec98e11..580fae644 100644 --- a/src/libtracker-data/tracker-db-manager.c +++ b/src/libtracker-data/tracker-db-manager.c @@ -40,6 +40,7 @@ #include "tracker-db-interface-sqlite.h" #include "tracker-db-interface.h" #include "tracker-data-manager.h" +#include "tracker-file-utils.h" #include "tracker-uuid.h" #define UNKNOWN_STATUS 0.5 diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-data/tracker-file-utils.c index 9994a079b..9994a079b 100644 --- a/src/libtracker-common/tracker-file-utils.c +++ b/src/libtracker-data/tracker-file-utils.c diff --git a/src/libtracker-common/tracker-file-utils.h b/src/libtracker-data/tracker-file-utils.h index 679a4543e..679a4543e 100644 --- a/src/libtracker-common/tracker-file-utils.h +++ b/src/libtracker-data/tracker-file-utils.h diff --git a/tests/libtracker-common/meson.build b/tests/libtracker-common/meson.build index a748e57f1..1d48ae512 100644 --- a/tests/libtracker-common/meson.build +++ b/tests/libtracker-common/meson.build @@ -1,6 +1,5 @@ libtracker_common_tests = [ 'date-time', - 'file-utils', 'utils', ] diff --git a/tests/libtracker-common/tracker-file-utils-test.c b/tests/libtracker-common/tracker-file-utils-test.c deleted file mode 100644 index 1286aa6e8..000000000 --- a/tests/libtracker-common/tracker-file-utils-test.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2008, Nokia <ivan.frade@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <string.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> -#include <locale.h> - -#include <glib.h> -#include <glib/gstdio.h> -#include <gio/gio.h> - -#include <libtracker-common/tracker-file-utils.h> -#include <libtracker-common/tracker-locale.h> - -#include <tracker-test-helpers.h> - -#define TEST_FILENAME "./file-utils-test.txt" -#define TEST_HIDDEN_FILENAME "./.hidden-file.txt" - -static void -ensure_file_exists (const gchar *filename) -{ - if (!g_file_test (filename, G_FILE_TEST_EXISTS)) { - g_file_set_contents (filename, "Just some stuff", -1, NULL); - } -} - -static void -remove_file (const gchar *filename) -{ - g_assert_true (g_file_test (filename, G_FILE_TEST_EXISTS)); - g_assert_cmpint (g_remove (filename), ==, 0); -} - -static void -test_file_utils_get_size () -{ - goffset size; - struct stat st; - - size = tracker_file_get_size (TEST_FILENAME); - g_assert_cmpint (size, >, 0); - - g_assert_cmpint (stat (TEST_FILENAME, &st), ==, 0); - g_assert_cmpint (size, ==, st.st_size); - - /* File doesn't exist */ - size = tracker_file_get_size ("./file-does-NOT-exist"); - g_assert_cmpint (size, ==, 0); -} - -static void -test_file_system_has_enough_space () -{ - /* Hopefully we will always have 1 byte free... */ - g_assert_true (tracker_file_system_has_enough_space ("/home", 1, FALSE)); - g_assert_true (tracker_file_system_has_enough_space ("/home", 1, TRUE)); - - /* gulong goes only up to 4Gb. Cannot ask for unreasonable amount of space */ - //g_assert_true (!tracker_file_system_has_enough_space ("/home", G_MAXULONG, FALSE)); -} - -int -main (int argc, char **argv) -{ - int result; - - g_test_init (&argc, &argv, NULL); - - setlocale (LC_ALL, ""); - - ensure_file_exists (TEST_FILENAME); - ensure_file_exists (TEST_HIDDEN_FILENAME); - - g_test_add_func ("/libtracker-common/file-utils/get_size", - test_file_utils_get_size); - g_test_add_func ("/libtracker-common/file-utils/has_enough_space", - test_file_system_has_enough_space); - - result = g_test_run (); - - remove_file (TEST_FILENAME); - remove_file (TEST_HIDDEN_FILENAME); - - return result; -} diff --git a/tests/libtracker-common/tracker-utils-test.c b/tests/libtracker-common/tracker-utils-test.c index 086c27185..b41f23990 100644 --- a/tests/libtracker-common/tracker-utils-test.c +++ b/tests/libtracker-common/tracker-utils-test.c @@ -21,7 +21,6 @@ #include "config.h" #include <glib-object.h> -#include <libtracker-common/tracker-file-utils.h> #include <libtracker-common/tracker-utils.h> #include <libtracker-common/tracker-locale.h> #include <locale.h> |