summaryrefslogtreecommitdiff
path: root/common/filelist-vfs-intf.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-12-13 14:36:33 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-12-13 14:36:33 +0100
commite42a4ff3031aa1c1aaf27aa34d9395fec185924b (patch)
tree51987665008a0f7a28c1351aaa4bb2eb1e37c46f /common/filelist-vfs-intf.c
parent016687cc49c811589951ebd064a86bdde1405866 (diff)
downloadtuxcmd-modules-0.6.74.tar.xz
Error system transformation to GErrorv0.6.74
Diffstat (limited to 'common/filelist-vfs-intf.c')
-rw-r--r--common/filelist-vfs-intf.c90
1 files changed, 52 insertions, 38 deletions
diff --git a/common/filelist-vfs-intf.c b/common/filelist-vfs-intf.c
index e806334..afb7a85 100644
--- a/common/filelist-vfs-intf.c
+++ b/common/filelist-vfs-intf.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <glib.h>
+#include <gio/gio.h>
#include "tuxcmd-vfs.h"
#include "strutils.h"
@@ -111,9 +112,12 @@ vfs_filelist_get_dir_size_break (struct VfsFilelistData *data)
/* -------------------------------------------------------------------------------------- */
-static void
-assign_file_info (struct PathTree* node, struct TVFSItem *Item, const char *reference_full_path, gboolean follow_symlinks, gboolean add_full_path)
+static struct TVFSItem *
+assign_file_info (struct PathTree* node, const char *reference_full_path, gboolean follow_symlinks, gboolean add_full_path)
{
+ struct TVFSItem *Item;
+
+ Item = g_malloc (sizeof (struct TVFSItem));
copy_vfs_item (node->data, Item);
if (add_full_path && reference_full_path) {
g_free (Item->FName);
@@ -126,10 +130,11 @@ assign_file_info (struct PathTree* node, struct TVFSItem *Item, const char *refe
Item->iPackedSize = node->symlink_target_data->iPackedSize;
Item->ItemType = node->symlink_target_data->ItemType;
}
+ return Item;
}
-TVFSResult
-vfs_filelist_file_info (struct VfsFilelistData *data, const char *AFileName, struct TVFSItem *Item, gboolean FollowSymlinks, gboolean AddFullPath)
+struct TVFSItem *
+vfs_filelist_file_info (struct VfsFilelistData *data, const char *AFileName, gboolean FollowSymlinks, gboolean AddFullPath, GError **error)
{
struct PathTree *node;
@@ -137,35 +142,39 @@ vfs_filelist_file_info (struct VfsFilelistData *data, const char *AFileName, str
node = filelist_tree_find_node_by_path (data->files, AFileName);
if (node) {
if (node->data) {
- assign_file_info (node, Item, AFileName, FollowSymlinks, AddFullPath);
- printf ("(II) VFSFileInfo: found file: '%s'\n", Item->FName);
- return cVFS_OK;
+ printf ("(II) vfs_filelist_file_info: found file: '%s'\n", node->node);
+ return assign_file_info (node, AFileName, FollowSymlinks, AddFullPath);
} else {
- printf ("(EE) VFSFileInfo: node->data == NULL! \n");
- return cVFS_Failed;
+ printf ("(EE) vfs_filelist_file_info: node->data == NULL! \n");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED, "node->data == NULL");
+ return NULL;
}
} else {
- printf ("(EE) VFSFileInfo: file specified not found\n");
- return cVFS_No_More_Files;
+ printf ("(EE) vfs_filelist_file_info: file specified not found\n");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "File specified not found.");
+ return NULL;
}
} else {
- printf ("(EE) VFSFileInfo: Invalid pointers to data objects.\n");
- return cVFS_Failed;
+ printf ("(EE) vfs_filelist_file_info: Invalid pointers to data objects.\n");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Invalid pointers to data objects.");
+ return NULL;
}
}
-TVFSResult
-vfs_filelist_list_first (struct VfsFilelistData *data, const char *sDir, struct TVFSItem *Item, gboolean FollowSymlinks, gboolean AddFullPath)
+struct TVFSItem *
+vfs_filelist_list_first (struct VfsFilelistData *data, const char *sDir, gboolean FollowSymlinks, gboolean AddFullPath, GError **error)
{
struct PathTree *node;
char *full_path;
+ struct TVFSItem *Item;
data->list_dir_index = -1;
data->list_dir_node = NULL;
if (sDir == NULL) {
- printf ("(EE) VFSListFirst: sDir is NULL!\n");
- return cVFS_Failed;
+ printf ("(EE) vfs_filelist_list_first: sDir is NULL!\n");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "NewPath is NULL");
+ return NULL;
}
data->list_dir_index = 0;
@@ -181,30 +190,33 @@ vfs_filelist_list_first (struct VfsFilelistData *data, const char *sDir, struct
full_path = NULL;
if (AddFullPath)
full_path = g_build_filename (sDir, node->data->FName, NULL);
- assign_file_info (node, Item, full_path, FollowSymlinks, AddFullPath);
+ Item = assign_file_info (node, full_path, FollowSymlinks, AddFullPath);
g_free (full_path);
- printf ("(II) VFSListFirst: found file: %s\n", Item->FName);
- return cVFS_OK;
+ printf ("(II) vfs_filelist_list_first: found file: %s\n", Item->FName);
+ return Item;
} else {
- printf ("(II) VFSListFirst: no more files\n");
- return cVFS_No_More_Files;
+ printf ("(II) vfs_filelist_list_first: no more files\n");
+ return NULL;
}
} else {
- printf ("(EE) VFSListFirst: Directory '%s' not found.\n", sDir);
- return cVFS_Failed;
+ printf ("(EE) vfs_filelist_list_first: Directory '%s' not found.\n", sDir);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Directory '%s' not found.", sDir);
+ return NULL;
}
}
-TVFSResult
-vfs_filelist_list_next (struct VfsFilelistData *data, struct TVFSItem *Item)
+struct TVFSItem *
+vfs_filelist_list_next (struct VfsFilelistData *data, GError **error)
{
struct PathTree *node;
char *full_path;
+ struct TVFSItem *Item;
full_path = NULL;
if (! data->list_dir_node) {
- printf ("(EE) VFSListNext: data->list_dir_node is NULL!\n");
- return cVFS_Failed;
+ printf ("(EE) vfs_filelist_list_next: data->list_dir_node is NULL!\n");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED, "data->list_dir_node is NULL");
+ return NULL;
}
data->list_dir_index++;
@@ -212,36 +224,37 @@ vfs_filelist_list_next (struct VfsFilelistData *data, struct TVFSItem *Item)
if (node) {
if (data->add_full_path)
full_path = g_build_filename (data->list_dir_path, node->data->FName, NULL);
- assign_file_info (node, Item, full_path, data->follow_symlinks, data->add_full_path);
+ Item = assign_file_info (node, full_path, data->follow_symlinks, data->add_full_path);
g_free (full_path);
- printf ("(II) VFSListNext: found file: %s\n", Item->FName);
- return cVFS_OK;
+ printf ("(II) vfs_filelist_list_next: found file: %s\n", Item->FName);
+ return Item;
} else {
- printf ("(II) VFSListNext: no more files\n");
- return cVFS_No_More_Files;
+ printf ("(II) vfs_filelist_list_next: no more files\n");
+ return NULL;
}
}
-TVFSResult
-vfs_filelist_list_close (struct VfsFilelistData *data)
+gboolean
+vfs_filelist_list_close (struct VfsFilelistData *data, GError **error)
{
data->list_dir_index = -1;
data->list_dir_node = NULL;
g_free (data->list_dir_path);
data->list_dir_path = NULL;
- return cVFS_OK;
+ return TRUE;
}
/* -------------------------------------------------------------------------------------- */
char *
-vfs_filelist_change_dir (struct VfsFilelistData *data, const char *NewPath)
+vfs_filelist_change_dir (struct VfsFilelistData *data, const char *NewPath, GError **error)
{
char *ANewPath;
if (NewPath == NULL) {
- printf("(EE) VFSChangeDir: NewPath is NULL!\n");
+ printf ("(EE) VFSChangeDir: NewPath is NULL!\n");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "NewPath is NULL");
return NULL;
}
@@ -258,6 +271,7 @@ vfs_filelist_change_dir (struct VfsFilelistData *data, const char *NewPath)
} else {
printf ("(EE) VFSChangeDir: Directory '%s' not found.\n", ANewPath);
g_free (ANewPath);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Directory '%s' not found.", ANewPath);
return NULL;
}
}