mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Following prototypes of functions was changed in VFS-module API:
* archive_check * archive_same * open_archive Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
e9ed6a41cf
commit
e6ec447585
@ -39,34 +39,30 @@ struct vfs_s_subclass test_subclass1, test_subclass2, test_subclass3;
|
||||
struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
|
||||
|
||||
static int
|
||||
test1_mock_open_archive(struct vfs_class *me, struct vfs_s_super *super,
|
||||
const vfs_path_t *vpath, char *op)
|
||||
test1_mock_open_archive(struct vfs_s_super *super, const vfs_path_t *vpath, const vfs_path_element_t *vpath_element)
|
||||
{
|
||||
struct vfs_s_inode *root;
|
||||
char *spath = vfs_path_to_str (vpath);
|
||||
|
||||
(void) op;
|
||||
|
||||
fail_unless(strcmp("/" ETALON_VFS_NAME ARCH_NAME, spath) == 0,
|
||||
"etalon(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_NAME ARCH_NAME, spath);
|
||||
|
||||
super->name = g_strdup (spath);
|
||||
super->data = g_new (char *, 1);
|
||||
root = vfs_s_new_inode (me, super, NULL);
|
||||
root = vfs_s_new_inode (vpath_element->class, super, NULL);
|
||||
super->root = root;
|
||||
g_free(spath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test1_mock_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
const vfs_path_t *vpath, char *op, void *cookie)
|
||||
test1_mock_archive_same (const vfs_path_element_t *vpath_element, struct vfs_s_super *super,
|
||||
const vfs_path_t *vpath, void *cookie)
|
||||
{
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index(vpath, -1);
|
||||
|
||||
(void) me;
|
||||
(void) vpath_element;
|
||||
(void) super;
|
||||
(void) op;
|
||||
(void) cookie;
|
||||
|
||||
if (strcmp(ARCH_NAME, path_element->path) != 0)
|
||||
|
@ -1069,8 +1069,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i
|
||||
|
||||
if (subclass->archive_check != NULL)
|
||||
{
|
||||
cookie =
|
||||
subclass->archive_check (path_element->class, vpath_archive, path_element->raw_url_str);
|
||||
cookie = subclass->archive_check (vpath_archive);
|
||||
if (cookie == NULL)
|
||||
{
|
||||
vfs_path_free (vpath_archive);
|
||||
@ -1085,8 +1084,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i
|
||||
super = (struct vfs_s_super *) iter->data;
|
||||
|
||||
/* 0 == other, 1 == same, return it, 2 == other but stop scanning */
|
||||
i = subclass->archive_same (path_element->class, super, vpath_archive,
|
||||
path_element->raw_url_str, cookie);
|
||||
i = subclass->archive_same (path_element, super, vpath_archive, cookie);
|
||||
if (i != 0)
|
||||
{
|
||||
if (i == 1)
|
||||
@ -1104,9 +1102,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i
|
||||
|
||||
super = vfs_s_new_super (path_element->class);
|
||||
if (subclass->open_archive != NULL)
|
||||
result =
|
||||
subclass->open_archive (path_element->class, super, vpath_archive,
|
||||
path_element->raw_url_str);
|
||||
result = subclass->open_archive (super, vpath_archive, path_element);
|
||||
if (result == -1)
|
||||
{
|
||||
vfs_s_free_super (path_element->class, super);
|
||||
|
@ -124,11 +124,11 @@ struct vfs_s_subclass
|
||||
void (*free_inode) (struct vfs_class * me, struct vfs_s_inode * ino); /* optional */
|
||||
int (*init_entry) (struct vfs_class * me, struct vfs_s_entry * entry); /* optional */
|
||||
|
||||
void *(*archive_check) (struct vfs_class * me, const vfs_path_t * vpath, char *op); /* optional */
|
||||
int (*archive_same) (struct vfs_class * me, struct vfs_s_super * psup,
|
||||
const vfs_path_t * vpath, char *op, void *cookie);
|
||||
int (*open_archive) (struct vfs_class * me, struct vfs_s_super * psup,
|
||||
const vfs_path_t * vpath, char *op);
|
||||
void *(*archive_check) (const vfs_path_t * vpath); /* optional */
|
||||
int (*archive_same) (const vfs_path_element_t * vpath_element, struct vfs_s_super * psup,
|
||||
const vfs_path_t * vpath, void *cookie);
|
||||
int (*open_archive) (struct vfs_s_super * psup,
|
||||
const vfs_path_t * vpath, const vfs_path_element_t * vpath_element);
|
||||
void (*free_archive) (struct vfs_class * me, struct vfs_s_super * psup);
|
||||
|
||||
int (*fh_open) (struct vfs_class * me, vfs_file_handler_t * fh, int flags, mode_t mode);
|
||||
|
@ -714,15 +714,15 @@ cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super)
|
||||
/** Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */
|
||||
|
||||
static int
|
||||
cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const vfs_path_t * vpath,
|
||||
char *op)
|
||||
cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
||||
const vfs_path_element_t * vpath_element)
|
||||
{
|
||||
int status = STATUS_START;
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
|
||||
(void) op;
|
||||
(void) vpath_element;
|
||||
|
||||
if (cpio_open_cpio_file (me, super, archive_name) == -1)
|
||||
if (cpio_open_cpio_file (vpath_element->class, super, archive_name) == -1)
|
||||
{
|
||||
g_free (archive_name);
|
||||
return -1;
|
||||
@ -730,7 +730,7 @@ cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const vfs_pa
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
status = cpio_read_head (me, super);
|
||||
status = cpio_read_head (vpath_element->class, super);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
@ -753,15 +753,12 @@ cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const vfs_pa
|
||||
/** Remaining functions are exactly same as for tarfs (and were in fact just copied) */
|
||||
|
||||
static void *
|
||||
cpio_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op)
|
||||
cpio_super_check (const vfs_path_t * vpath)
|
||||
{
|
||||
static struct stat sb;
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
int stat_result;
|
||||
|
||||
(void) me;
|
||||
(void) op;
|
||||
|
||||
stat_result = mc_stat (archive_name, &sb);
|
||||
g_free (archive_name);
|
||||
return (stat_result == 0 ? &sb : NULL);
|
||||
@ -770,14 +767,13 @@ cpio_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc,
|
||||
const vfs_path_t * vpath, char *op, void *cookie)
|
||||
cpio_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *parc,
|
||||
const vfs_path_t * vpath, void *cookie)
|
||||
{
|
||||
struct stat *archive_stat = cookie; /* stat of main archive */
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
|
||||
(void) me;
|
||||
(void) op;
|
||||
(void) vpath_element;
|
||||
|
||||
if (strcmp (parc->name, archive_name))
|
||||
{
|
||||
|
@ -581,15 +581,17 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, char *op)
|
||||
fish_open_archive (struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, const vfs_path_element_t * vpath_element)
|
||||
{
|
||||
(void) vpath;
|
||||
|
||||
super->data = g_new0 (fish_super_data_t, 1);
|
||||
super->path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
super->path_element =
|
||||
vfs_url_split (strchr (vpath_element->raw_url_str, ':') + 1, 0,
|
||||
URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
|
||||
if (strncmp (op, "rsh:", 4) == 0)
|
||||
if (strncmp (vpath_element->raw_url_str, "rsh:", 4) == 0)
|
||||
super->path_element->port = FISH_FLAG_RSH;
|
||||
|
||||
SUP->scr_ls =
|
||||
@ -631,23 +633,24 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
|
||||
fish_load_script_from_file (super->path_element->host, FISH_INFO_FILE,
|
||||
FISH_INFO_DEF_CONTENT);
|
||||
|
||||
return fish_open_archive_int (me, super);
|
||||
return fish_open_archive_int (vpath_element->class, super);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
fish_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, char *op, void *cookie)
|
||||
fish_archive_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, void *cookie)
|
||||
{
|
||||
vfs_path_element_t *path_element;
|
||||
int result;
|
||||
|
||||
(void) me;
|
||||
(void) vpath;
|
||||
(void) cookie;
|
||||
|
||||
path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
path_element =
|
||||
vfs_url_split (strchr (vpath_element->raw_url_str, ':') + 1, 0,
|
||||
URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
|
||||
if (path_element->user == NULL)
|
||||
path_element->user = vfs_get_local_username ();
|
||||
|
@ -959,14 +959,14 @@ ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, char *op)
|
||||
ftpfs_open_archive (struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, const vfs_path_element_t * vpath_element)
|
||||
{
|
||||
(void) vpath;
|
||||
|
||||
super->data = g_new0 (ftp_super_data_t, 1);
|
||||
|
||||
super->path_element = ftpfs_split_url (strchr (op, ':') + 1);
|
||||
super->path_element = ftpfs_split_url (strchr (vpath_element->raw_url_str, ':') + 1);
|
||||
SUP->proxy = NULL;
|
||||
if (ftpfs_check_proxy (super->path_element->host))
|
||||
SUP->proxy = ftpfs_proxy_host;
|
||||
@ -975,25 +975,26 @@ ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super,
|
||||
SUP->isbinary = TYPE_UNKNOWN;
|
||||
SUP->remote_is_amiga = 0;
|
||||
super->name = g_strdup ("/");
|
||||
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat (me, S_IFDIR | 0755));
|
||||
super->root =
|
||||
vfs_s_new_inode (vpath_element->class, super,
|
||||
vfs_s_default_stat (vpath_element->class, S_IFDIR | 0755));
|
||||
|
||||
return ftpfs_open_archive_int (me, super);
|
||||
return ftpfs_open_archive_int (vpath_element->class, super);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, char *op, void *cookie)
|
||||
ftpfs_archive_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, void *cookie)
|
||||
{
|
||||
vfs_path_element_t *path_element;
|
||||
int result;
|
||||
|
||||
(void) me;
|
||||
(void) vpath;
|
||||
(void) cookie;
|
||||
|
||||
path_element = ftpfs_split_url (strchr (op, ':') + 1);
|
||||
path_element = ftpfs_split_url (strchr (vpath_element->raw_url_str, ':') + 1);
|
||||
|
||||
result = ((strcmp (path_element->host, super->path_element->host) == 0)
|
||||
&& (strcmp (path_element->user, super->path_element->user) == 0)
|
||||
|
@ -287,7 +287,7 @@ tar_open_archive_int (struct vfs_class *me, const vfs_path_t * vpath, struct vfs
|
||||
if (result == -1)
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), archive_name);
|
||||
g_free(archive_name);
|
||||
g_free (archive_name);
|
||||
ERRNOR (ENOENT, -1);
|
||||
}
|
||||
|
||||
@ -729,19 +729,17 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
static int
|
||||
tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_path_t * vpath,
|
||||
char *op)
|
||||
tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
|
||||
const vfs_path_element_t * vpath_element)
|
||||
{
|
||||
/* Initial status at start of archive */
|
||||
ReadStatus status = STATUS_EOFMARK;
|
||||
ReadStatus prev_status;
|
||||
int tard;
|
||||
|
||||
(void) op;
|
||||
|
||||
current_tar_position = 0;
|
||||
/* Open for reading */
|
||||
tard = tar_open_archive_int (me, vpath, archive);
|
||||
tard = tar_open_archive_int (vpath_element->class, vpath, archive);
|
||||
if (tard == -1)
|
||||
return -1;
|
||||
|
||||
@ -750,7 +748,7 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_p
|
||||
size_t h_size;
|
||||
|
||||
prev_status = status;
|
||||
status = tar_read_header (me, archive, tard, &h_size);
|
||||
status = tar_read_header (vpath_element->class, archive, tard, &h_size);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
@ -772,10 +770,10 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_p
|
||||
/* Error on first record */
|
||||
case STATUS_EOFMARK:
|
||||
{
|
||||
char *archive_name = vfs_path_to_str(vpath);
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
message (D_ERROR, MSG_ERROR, _("%s\ndoesn't look like a tar archive."),
|
||||
archive_name);
|
||||
g_free(archive_name);
|
||||
g_free (archive_name);
|
||||
/* FALL THRU */
|
||||
|
||||
/* Error after header rec */
|
||||
@ -806,17 +804,14 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_p
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
tar_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op)
|
||||
tar_super_check (const vfs_path_t * vpath)
|
||||
{
|
||||
static struct stat stat_buf;
|
||||
char *archive_name = vfs_path_to_str(vpath);
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
int stat_result;
|
||||
|
||||
(void) me;
|
||||
(void) op;
|
||||
|
||||
stat_result = mc_stat (archive_name, &stat_buf);
|
||||
g_free(archive_name);
|
||||
g_free (archive_name);
|
||||
|
||||
return (stat_result != 0) ? NULL : &stat_buf;
|
||||
}
|
||||
@ -824,21 +819,20 @@ tar_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
tar_super_same (struct vfs_class *me, struct vfs_s_super *parc,
|
||||
const vfs_path_t * vpath, char *op, void *cookie)
|
||||
tar_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *parc,
|
||||
const vfs_path_t * vpath, void *cookie)
|
||||
{
|
||||
struct stat *archive_stat = cookie; /* stat of main archive */
|
||||
char *archive_name = vfs_path_to_str(vpath);
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
|
||||
(void) me;
|
||||
(void) op;
|
||||
(void) vpath_element;
|
||||
|
||||
if (strcmp (parc->name, archive_name) != 0)
|
||||
{
|
||||
g_free(archive_name);
|
||||
g_free (archive_name);
|
||||
return 0;
|
||||
}
|
||||
g_free(archive_name);
|
||||
g_free (archive_name);
|
||||
|
||||
/* Has the cached archive been changed on the disk? */
|
||||
if (((tar_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime)
|
||||
|
Loading…
Reference in New Issue
Block a user