#include <stdlib.h>
#include <string.h>
-
#define PATTERN_FILE_SIZE 0x10000
-
#define TEST_HANDLE_SPECIAL TRUE
enum StructureExtraFlags
#define TEST_TARGET_FILE "target-file"
-const struct StructureItem sample_struct[] = {
+static const struct StructureItem sample_struct[] = {
/* filename link file_type create_flags mode | handle_special | extra_flags */
{"dir1", NULL, G_FILE_TYPE_DIRECTORY, G_FILE_CREATE_NONE, 0, 0, TEST_DELETE_NORMAL | TEST_DELETE_NON_EMPTY | TEST_REPLACE | TEST_OPEN},
{"dir1/subdir", NULL, G_FILE_TYPE_DIRECTORY, G_FILE_CREATE_NONE, 0, 0, TEST_COPY | TEST_COPY_ERROR_RECURSE | TEST_APPEND},
{"lost_symlink", "nowhere", G_FILE_TYPE_SYMBOLIC_LINK, G_FILE_CREATE_NONE, 0, 0, TEST_COPY | TEST_DELETE_NORMAL | TEST_OPEN | TEST_INVALID_SYMLINK},
};
-
-
-
static gboolean write_test;
static gboolean verbose;
static gboolean posix_compat;
#define log(msg...) if (verbose) g_print (msg)
-
-
-
-
-
-
-GFile *
+static GFile *
create_empty_file (GFile * parent, const char *filename,
GFileCreateFlags create_flags)
{
GError *error;
GFileOutputStream *outs;
-
child = g_file_get_child (parent, filename);
g_assert (child != NULL);
return child;
}
-GFile *
+static GFile *
create_empty_dir (GFile * parent, const char *filename)
{
GFile *child;
return child;
}
-GFile *
+static GFile *
create_symlink (GFile * parent, const char *filename, const char *points_to)
{
GFile *child;
int i;
struct StructureItem item;
-
g_assert (test_data != NULL);
log ("\n Going to create testing structure in '%s'...\n",
(char *) test_data);
res = g_file_make_directory (root, NULL, NULL);
/* don't care about errors here */
-
/* create any other items */
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
{
g_object_unref (root);
}
-
-
-
-
-GFile *
+static GFile *
file_exists (GFile * parent, const char *filename, gboolean * result)
{
GFile *child;
return child;
}
-void
+static void
test_attributes (struct StructureItem item, GFileInfo * info)
{
GFileType ftype;
}
}
-
static void
test_initial_structure (gconstpointer test_data)
{
res = g_file_query_exists (root, NULL);
g_assert_cmpint (res, ==, TRUE);
-
/* test the structure */
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
{
g_object_unref (child);
}
-
/* read and test the pattern file */
log (" Testing pattern file...\n");
child = file_exists (root, "pattern_file", &res);
g_object_unref (root);
}
-
-
-
-
-
-void
+static void
traverse_recurse_dirs (GFile * parent, GFile * root)
{
gboolean res;
int i;
gboolean found;
-
g_assert (root != NULL);
error = NULL;
}
g_assert (error == NULL);
-
error = NULL;
res = g_file_enumerator_close (enumerator, NULL, &error);
g_assert_cmpint (res, ==, TRUE);
g_object_unref (root);
}
-
-
-
-
-
-void
+static void
do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
enum StructureExtraFlags extra_flags)
{
log (" res = %d, error code %d = %s\n", res, error->code,
error->message);
-
/* copying file/directory to itself (".") */
if (((item.extra_flags & TEST_NOT_EXISTS) != TEST_NOT_EXISTS) &&
(extra_flags == TEST_ALREADY_EXISTS))
int i;
struct StructureItem item;
-
log ("\n");
g_assert (test_data != NULL);
g_object_unref (root);
}
-
-
-
-
static void
test_create (gconstpointer test_data)
{
struct StructureItem item;
GFileOutputStream *os;
-
g_assert (test_data != NULL);
log ("\n");
res = g_file_query_exists (root, NULL);
g_assert_cmpint (res, ==, TRUE);
-
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
{
item = sample_struct[i];
if (error)
log (" error code %d = %s\n", error->code, error->message);
-
if (((item.extra_flags & TEST_NOT_EXISTS) == 0) &&
((item.extra_flags & TEST_CREATE) == TEST_CREATE))
{
g_object_unref (root);
}
-
-
-
static void
test_open (gconstpointer test_data)
{
struct StructureItem item;
GFileInputStream *input_stream;
-
g_assert (test_data != NULL);
log ("\n");
res = g_file_query_exists (root, NULL);
g_assert_cmpint (res, ==, TRUE);
-
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
{
item = sample_struct[i];
g_object_unref (root);
}
-
-
-
-
static void
test_delete (gconstpointer test_data)
{
int i;
struct StructureItem item;
-
g_assert (test_data != NULL);
log ("\n");
g_error_free (error);
}
-
g_object_unref (child);
}
}
g_object_unref (root);
}
-
-
-
-
-
-
int
main (int argc, char *argv[])
{
}
target_path = strdup (argv[1]);
-
-
/* Write test - create new testing structure */
if (write_test || create_struct)
g_test_add_data_func ("/live-g-file/create_structure", target_path,