Zip / Unzip with relative path

186 views
Skip to first unread message

Charly 9000

unread,
Mar 1, 2024, 1:38:18 PM3/1/24
to Harbour Users
Hello,

Any way to compress files in a folder with its subdirectories and decompress with its relative path, not absolute?

Yes I have
c:\a\b\c\d\e\
And I compress c:\a\b\c\*.*

If I unzip to any directory it would create me
*.*
d\*.*
d\e\*.*

Thanks
C.

trepao2...@gmail.com

unread,
Mar 1, 2024, 4:09:04 PM3/1/24
to Harbour Users
Perhaps previous cd command (change directory) can help you

c:
cd\a\b\c
winzip a -r Files *.*

Charly 9000

unread,
Mar 2, 2024, 1:59:33 AM3/2/24
to Harbour Users
With harbour functions :-)

C.

Mario H. Sabado

unread,
Mar 2, 2024, 3:25:24 AM3/2/24
to harbou...@googlegroups.com
Hi Charly,

I tested the myzip.prg tests under harbour\contrib\hbmzip.  Please see below if the result is what you are looking for.

Best regards,
Mario

*************************************************************
C:\Temp>myzip test1.zip test_zip\*.*

Archive file: test1.zip
Adding test_zip\test1\test1.txt
Adding test_zip\test1\test2\test2.txt
Adding test_zip\test1.txt
************************************************************

C:\Temp>7z l test1.zip
7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20

Scanning the drive for archives:
1 file, 433 bytes (1 KiB)

Listing archive: test1.zip
--
Path = test1.zip
Type = zip
Physical Size = 433

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2024-03-02 16:16:30 ....A           11           13  test_zip\test1\test1.txt
2024-03-02 16:16:16 ....A           11           13  test_zip\test1\test2\test2.txt
2024-03-02 16:16:46 ....A           11           13  test_zip\test1.txt
------------------- ----- ------------ ------------  ------------------------
2024-03-02 16:16:46                 33           39  3 files
************************************************************************************************

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/29494768-6903-4838-a254-9f0dd2a6ca8fn%40googlegroups.com.

Charly 9000

unread,
Mar 2, 2024, 7:38:19 AM3/2/24
to Harbour Users
I was really unaware of this contribution. Thanks Mario ! :-)

Mario H. Sabado

unread,
Mar 2, 2024, 8:00:43 AM3/2/24
to harbou...@googlegroups.com
You're welcome, Charly.  Glad you can use this great tool in your project.

BTW, Viktor's HB34 fork has added memory support in case you need this functionality.

***************************************************
2017-10-10 20:23 UTC Viktor Szakats
  * contrib/hbmzip/hbmzip.hbx
  * contrib/hbmzip/mzip.c
  * contrib/hbmzip/tests/myunzip.prg
  * contrib/hbmzip/tests/myzip.prg
    + add new functions to zip/unzip to/from memory (= strings):
      hb_unzipExtractCurrentFileToMem( hUnzip, [ cPassword ], @cContent ) --> nError
         nError: -300 --> uncompressed size too large, current limit is 256 MiB
      hb_zipStoreFileMem( hZip, cContent, cFileName, [ cPassword ], [ cComment ], [ lUnicode ] ) --> nError
    ! fix to handle errors returned by zipWriteInFileInZip() calls
    ! fix minor typos in comments and constant names
    + add tests
****************************************

Best Regards,
Mario

Reply all
Reply to author
Forward
0 new messages