Closed roytam1 closed 12 years ago
Thanks for the patch. Would you be willing to rework it slightly?
I've set up the lha_arch layer to separate the architecture-specific code from the non-specific code, to specifically avoid putting "#if LHA_ARCH ==" throughout the program. So if vasprintf is a problem on Windows, it should be moved into the layer.
Also, I'm a bit confused as to why mkdir() needs to ignore existing directories. As far as I know, the extraction code should only be creating directories if they don't already exist. Is this not the case?
Thanks!
Also, I'm a bit confused as to why mkdir() needs to ignore existing directories. As far as I know, the extraction code should only be creating directories if they don't already exist. Is this not the case?
I didn't dig though the sources, but it creates the directory and it checks the newly created directory every file that inside that directory when extracting.
EDIT:
LHAFileType lha_arch_exists(char *filename)
{
// TODO
return LHA_FILE_NONE;
}
so that's the problem.
file: http://homepage3.nifty.com/csdinc/archiver/lib/bga32037.lzh
without the patch:
16:42 D:\>lha bga32037.lzh
PERMSSN UID GID SIZE RATIO STAMP NAME
---------- ----------- ------- ------ ------------ --------------------
[MS-DOS] 372736 57.1% Jun 4 2002 Bga32.dll
[MS-DOS] 19586 37.7% Jun 4 2002 Bga32.txt
[MS-DOS] 0 ****** Jun 4 2002 sdk/
[MS-DOS] 25338 24.2% Jun 4 2002 SDK/Bga32Api.txt
[MS-DOS] 14911 33.7% Jun 4 2002 SDK/Bga32Cmd.txt
[MS-DOS] 17213 29.3% Jun 4 2002 SDK/Bga32Api.h
[MS-DOS] 6144 20.5% Jun 4 2002 SDK/Bga32.lib
---------- ----------- ------- ------ ------------ --------------------
Total 7 files 455928 52.2% Oct 18 2010
16:42 D:\>lha x bga32037.lzh
Bga32.dll - Melted : oooooooooooooooooooooooooooooooooooooooooooooo
Bga32.txt - Melted : ooo
Failed to create parent directory SDK/
Failed to create parent directory SDK/
Failed to create parent directory SDK/
Failed to create parent directory SDK/
16:43 D:\>dir/b sdk
with the patch:
16:43 D:\>lha x bga32037.lzh
Bga32.dll - Melted : oooooooooooooooooooooooooooooooooooooooooooooo
Bga32.txt - Melted : ooo
SDK/Bga32Api.txt - Melted : oooo
SDK/Bga32Cmd.txt - Melted : oo
SDK/Bga32Api.h - Melted : ooo
SDK/Bga32.lib - Melted : o
16:44 D:\>dir/b sdk
Bga32.lib
Bga32Api.h
Bga32Api.txt
Bga32Cmd.txt
Thanks for the patch. Would you be willing to rework it slightly?
Sure.
diff --git a/lib/lha_arch_win32.c b/lib/lha_arch_win32.c
index c01b3a6..15d86e9 100644
--- a/lib/lha_arch_win32.c
+++ b/lib/lha_arch_win32.c
@@ -32,10 +32,26 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <utime.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <errno.h>
+#include <stdarg.h>
+
+int vasprintf( char **sptr, char *fmt, va_list argv )
+{
+ int wanted = vsnprintf( *sptr = NULL, 0, fmt, argv );
+ if( (wanted > 0) && ((*sptr = malloc( 1 + wanted )) != NULL) )
+ return vsprintf( *sptr, fmt, argv );
+
+ return wanted;
+}
int lha_arch_mkdir(char *path, unsigned int unix_mode)
{
- return mkdir(path) == 0;
+ int i;
+
+ i = mkdir(path);
+ if(i < 0 && errno == EEXIST) /* ignore if dir exists */
+ i = 0;
+ return i == 0;
}
int lha_arch_chown(char *filename, int unix_uid, int unix_gid)
Ah, I see. The problem is with lha_arch_exists, not lha_arch_mkdir.
Several functions in lha_arch_win32.c aren't implemented yet. I'm hoping to put together a fully working and tested MingW build soon - as you can see it's rather sketchy at the moment.
Hi,
I've implemented the incomplete functions in lha_arch_win32.c and got the test suite running on Windows. The current version on head passes all tests, so hopefully it should work a bit better for you.
Thanks!
this patch fix 2 issues: