summaryrefslogtreecommitdiff
path: root/unrar
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-11-14 22:09:33 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-11-14 22:09:33 +0100
commit4fd3fefa6db8b77915bc67d4623ef3176a431004 (patch)
treecdba97582884d354aa4686efc6fc10f0f1e8663b /unrar
parentab2b62982be3224e921eead9c232f82c50567cd8 (diff)
downloadtuxcmd-modules-4fd3fefa6db8b77915bc67d4623ef3176a431004.tar.xz
unrar plugin: Show prompt when a volume is missingv0.6.58
Diffstat (limited to 'unrar')
-rw-r--r--unrar/unrar.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/unrar/unrar.c b/unrar/unrar.c
index b1282e7..47e3cb3 100644
--- a/unrar/unrar.c
+++ b/unrar/unrar.c
@@ -71,7 +71,8 @@ struct TVFSGlobs {
char *archive_path;
gboolean need_password;
- gboolean passwd_callback;
+ gboolean failed_passwd_callback;
+ gboolean volume_missing_abort;
char *password;
unsigned long block_size;
@@ -109,7 +110,8 @@ VFSNew (TVFSLogFunc log_func)
globs->block_size = DEFAULT_BLOCK_SIZE;
globs->need_password = FALSE;
- globs->passwd_callback = FALSE;
+ globs->failed_passwd_callback = FALSE;
+ globs->volume_missing_abort = FALSE;
globs->password = NULL;
globs->callback_data = NULL;
@@ -197,31 +199,29 @@ int unrar_callback(UINT msg, LONG UserData, LONG P1, LONG P2)
if (P1) {
if (globs->callback_ask_question) {
static const char *choices[] = {
- "Cancel",
- "Continue",
+ "Abort", /* response = 0 */
+ "Ignore", /* response = 1 */
NULL
};
- char *message;
- int choice = 2;
+ char *message, *s;
+ int choice = -1;
- message = g_strdup_printf ("volume missing: %s", (char *)P1);
- globs->callback_ask_question (message, choices, &choice, 0,
+ s = g_filename_to_utf8 ((char *)P1, -1, NULL, NULL, NULL);
+ message = g_strdup_printf ("Archive is incomplete, volume missing: \n\n%s", s ? s : (char *)P1);
+ globs->callback_ask_question (message, &choices[0], &choice, 0,
globs->callback_data);
g_free (message);
- switch (choice) {
- case 0: /* Cancel */
- return -1;
- case 1: /* Continue */
- return 0;
- /* Any other options? */
+ if (s) g_free (s);
+
+ if (choice != 1)
+ globs->volume_missing_abort = TRUE;
+ return -1;
+ } else {
+ if (access((char*)P1, R_OK) != 0) {
+ fprintf(stderr, "(EE) unrar_callback: UCM_CHANGEVOLUME message, RAR_VOL_ASK: access test failed - missing part? Error = %s \n", strerror(errno));
+ return -1;
}
}
-/*
- if (access((char*)P1, R_OK) != 0) {
- fprintf(stderr, "(EE) unrar_callback: UCM_CHANGEVOLUME message, RAR_VOL_ASK: access test failed - missing part? Error = %s \n", strerror(errno));
- return -1;
- }
-*/
}
} else
if (P2 == RAR_VOL_NOTIFY) {
@@ -256,7 +256,7 @@ int unrar_callback(UINT msg, LONG UserData, LONG P1, LONG P2)
char *passwd = NULL;
int res = FALSE;
- globs->passwd_callback = TRUE;
+ globs->failed_passwd_callback = TRUE;
if (globs->callback_ask_password) {
res = globs->callback_ask_password ("The archive is encrypted and requires password",
NULL, NULL, NULL, VFS_ASK_PASSWORD_NEED_PASSWORD | VFS_ASK_PASSWORD_ARCHIVE_MODE,
@@ -323,7 +323,8 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName)
globs->curr_dir = NULL;
globs->archive_path = strdup(sName);
globs->total_size = 0;
- globs->passwd_callback = FALSE;
+ globs->failed_passwd_callback = FALSE;
+ globs->volume_missing_abort = FALSE;
fprintf(stderr, "(--) VFSOpen: trying to open archive '%s'...\n", globs->archive_path);
HANDLE PASCAL handle;
@@ -401,10 +402,10 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName)
if (res2) printf("RARProcessFile result = %d\n", res2);
}
// printf("\nRARReadHeader result = %d\n", res);
- if (res != ERAR_END_ARCHIVE) {
+ if (res != ERAR_END_ARCHIVE || globs->volume_missing_abort) {
fprintf(stderr, "(EE) VFSOpen: RARReadHeader result = %d\n", res);
Result = cVFS_Failed;
- if ((res == ERAR_MISSING_PASSWORD) || ((res == ERAR_BAD_DATA) && (globs->passwd_callback)))
+ if ((res == ERAR_MISSING_PASSWORD) || ((res == ERAR_BAD_DATA) && (globs->failed_passwd_callback)))
Result = cVFS_BadPassword;
}
free(header);