ferdnyc / rpms / chmlib

Forked from rpms/chmlib 4 years ago
Clone
f808a5c
From 5998ff5105a9cd3f684519927e2ac78d3b6a3c30 Mon Sep 17 00:00:00 2001
3f88070
From: Jed Wing <jed.wing@gmail.com>
3f88070
Date: Wed, 27 May 2009 18:41:10 -0700
f808a5c
Subject: [PATCH 2/2] Fix for extract_chmLib confusing empty files with
f808a5c
 directories.
3f88070
3f88070
Patch from Paul Wise <pabs@debian.org> via Kartik Mistry, the maintainer of the
3f88070
Debian chmlib package.
3f88070
---
f808a5c
 src/extract_chmLib.c | 7 ++++++-
f808a5c
 1 file changed, 6 insertions(+), 1 deletion(-)
3f88070
3f88070
diff --git a/src/extract_chmLib.c b/src/extract_chmLib.c
3f88070
index 078cc35..478c892 100644
3f88070
--- a/src/extract_chmLib.c
3f88070
+++ b/src/extract_chmLib.c
3f88070
@@ -102,6 +102,7 @@ int _extract_callback(struct chmFile *h,
3f88070
               struct chmUnitInfo *ui,
3f88070
               void *context)
3f88070
 {
3f88070
+    LONGUINT64 ui_path_len;
3f88070
     char buffer[32768];
3f88070
     struct extract_context *ctx = (struct extract_context *)context;
3f88070
     char *i;
3f88070
@@ -119,7 +120,11 @@ int _extract_callback(struct chmFile *h,
3f88070
     if (snprintf(buffer, sizeof(buffer), "%s%s", ctx->base_path, ui->path) > 1024)
3f88070
         return CHM_ENUMERATOR_FAILURE;
3f88070
 
3f88070
-    if (ui->length != 0)
3f88070
+    /* Get the length of the path */
3f88070
+    ui_path_len = strlen(ui->path)-1;
3f88070
+
3f88070
+    /* Distinguish between files and dirs */
3f88070
+    if (ui->path[ui_path_len] != '/' )
3f88070
     {
3f88070
         FILE *fout;
3f88070
         LONGINT64 len, remain=ui->length;
3f88070
-- 
f808a5c
1.8.3.1
3f88070