diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-12-13 14:36:33 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-12-13 14:36:33 +0100 |
| commit | e42a4ff3031aa1c1aaf27aa34d9395fec185924b (patch) | |
| tree | 51987665008a0f7a28c1351aaa4bb2eb1e37c46f /common | |
| parent | 016687cc49c811589951ebd064a86bdde1405866 (diff) | |
| download | tuxcmd-modules-0.6.74.tar.xz | |
Error system transformation to GErrorv0.6.74
Diffstat (limited to 'common')
| -rw-r--r-- | common/filelist-vfs-intf.c | 90 | ||||
| -rw-r--r-- | common/filelist-vfs-intf.h | 10 | ||||
| -rw-r--r-- | common/tuxcmd-vfs.h | 25 |
3 files changed, 61 insertions, 64 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; } } diff --git a/common/filelist-vfs-intf.h b/common/filelist-vfs-intf.h index ff3eeef..d781e70 100644 --- a/common/filelist-vfs-intf.h +++ b/common/filelist-vfs-intf.h @@ -52,13 +52,13 @@ guint64 vfs_filelist_get_dir_size (struct VfsFilelistData *data, const char void vfs_filelist_get_dir_size_break (struct VfsFilelistData *data); gboolean vfs_filelist_file_exists (struct VfsFilelistData *data, const char *FileName, const long Use_lstat); -TVFSResult vfs_filelist_file_info (struct VfsFilelistData *data, const char *AFileName, struct TVFSItem *Item, gboolean FollowSymlinks, gboolean AddFullPath); -TVFSResult vfs_filelist_list_first (struct VfsFilelistData *data, const char *sDir, struct TVFSItem *Item, gboolean FollowSymlinks, gboolean AddFullPath); -TVFSResult vfs_filelist_list_next (struct VfsFilelistData *data, struct TVFSItem *Item); -TVFSResult vfs_filelist_list_close (struct VfsFilelistData *data); +struct TVFSItem * vfs_filelist_file_info (struct VfsFilelistData *data, const char *AFileName, gboolean FollowSymlinks, gboolean AddFullPath, GError **error); +struct TVFSItem * vfs_filelist_list_first (struct VfsFilelistData *data, const char *sDir, gboolean FollowSymlinks, gboolean AddFullPath, GError **error); +struct TVFSItem * vfs_filelist_list_next (struct VfsFilelistData *data, GError **error); +gboolean vfs_filelist_list_close (struct VfsFilelistData *data, GError **error); -char * vfs_filelist_change_dir (struct VfsFilelistData *data, const char *NewPath); +char * vfs_filelist_change_dir (struct VfsFilelistData *data, const char *NewPath, GError **error); diff --git a/common/tuxcmd-vfs.h b/common/tuxcmd-vfs.h index 2ced1b1..309b43c 100644 --- a/common/tuxcmd-vfs.h +++ b/common/tuxcmd-vfs.h @@ -27,10 +27,8 @@ extern "C" { #endif - #include <glib.h> -typedef int TVFSResult; /* Compatible with gio/GAskPasswordFlags */ typedef enum { @@ -43,6 +41,7 @@ typedef enum { VFS_ASK_PASSWORD_ARCHIVE_MODE = 1 << 15 } TVFSAskPasswordFlags; + /* Compatible with gio/GPasswordSave */ typedef enum { VFS_PASSWORD_SAVE_NEVER, @@ -50,6 +49,7 @@ typedef enum { VFS_PASSWORD_SAVE_PERMANENTLY } TVFSPasswordSave; + /* Module capability flags */ typedef enum { VFS_CAP_HANDLES_MULTIPLE_REQUESTS = 1 << 0, /* Multiple (background) operations; usually unsuitable for archives */ @@ -59,6 +59,7 @@ typedef enum { } TVFSModuleCapabilities; + typedef void (* TVFSLogFunc) (const char *s); typedef void * TVFSFileDes; @@ -66,7 +67,7 @@ typedef void * TVFSFileDes; /* Return FALSE to break the operation */ typedef gboolean (* TVFSProgressCallback) (guint64 position, - guint64 max, + GError *error, void *user_data); /* Return index of the choice selected or negative number when dialog has been cancelled */ @@ -94,24 +95,6 @@ typedef gboolean (* TVFSAskPasswordCallback) /* current version of the VFS API */ static const int cVFSVersion = 5; -/* error codes (TVFSResult) */ -enum { - cVFS_OK = 0, - cVFS_Failed = 1, /* also No such file */ - cVFS_Cancelled = 2, - cVFS_Not_Supported = 3, - cVFS_No_More_Files = 4, - cVFS_ReadErr = 5, - cVFS_WriteErr = 6, /* also Readonly FileSystem */ - cVFS_LoginFailed = 7, - cVFS_PermissionDenied = 8, - cVFS_NoSpaceLeft = 9, - cVFS_mallocFailed = 10, - cVFS_BadPassword = 11, - cVFS_MissingVolume = 12, - cVFS_CorruptedArchive = 13 -}; - /* open modes */ enum { |
