Page 1 of 1

Comprimir con Harbour + FW ... por favor...

Posted: Sun May 21, 2006 2:22 pm
by AngelSalom
Hola, holita gente.
Ando mareado de un lado a otro y no consigo entender si es posible realizar archivos comprimidos (me da igual ZIP, que cualquier otro formato) con Harbour + FW (si, ya se que xHarbour tiene la contribución HBZIP que es fabulosa y tal ... ) pero con Harbour no carbura... o soy yo que no se compilarla correctamente.
Y no me sirve usar Winexec () a programas externos, ya que tengo que controlar rigurosamente el proceso porque si falla algo debo saberlo.
Alguien conoce algún método ???

Mil gracias.

Intentando algo ...

Posted: Sun May 21, 2006 4:24 pm
by AngelSalom
He encontrado una dll zip32.dll que trae ejemplos en visual basic.
Lo cierto es que es la primera vez que intento esto, por lo tanto estoy muy "pardillo" en el tema, pero bueno.

Esto es lo que he hecho :

------ Este es el código en vb -------

Public Type ZIPUSERFUNCTIONS
DLLPrnt As Long
DLLPassword As Long
DLLComment As Long
DLLService As Long
End Type

Public Type ZPOPT
fSuffix As Long
fEncrypt As Long
fSystem As Long
fVolume As Long
fExtra As Long
fNoDirEntries As Long
fExcludeDate As Long
fIncludeDate As Long
fVerbose As Long
fQuiet As Long
fCRLF_LF As Long
fLF_CRLF As Long
fJunkDir As Long
fRecurse As Long
fGrow As Long
fForce As Long
fMove As Long
fDeleteEntries As Long
fUpdate As Long
fFreshen As Long
fJunkSFX As Long
fLatestTime As Long
fComment As Long
fOffsets As Long
fPrivilege As Long
fEncryption As Long
fRepair As Long
flevel As Byte
date As String
szRootDir As String
End Type

Public Type ZIPnames
s(0 To 99) As String
End Type

Public Declare Function ZpInit Lib "zip32.dll" (ByRef Zipfun As ZIPUSERFUNCTIONS) As Long

Public Declare Function ZpSetOptions Lib "zip32.dll" (ByRef Opts As ZPOPT) As Long

Public Declare Function ZpArchive Lib "zip32.dll" (ByVal argc As Long, ByVal funame As String, ByRef argv As ZIPnames) As Long

------------------------------------------------------------------------

--- Este es mi "intento" de traducirlo -------------
/* -----------------------------------------------------------------------------------
Pruebas con archivos ZIP
-----------------------------------------------------------------------------------
*/

#include "fivewin.ch"
#include "struct.ch"

Function Main()
Private oZipUserFunctions, ozPopt, oZipNames, oZipFun, oOpts, nArgC, cFuName, oArgV

STRUCT oZipUserFunctions
MEMBER DLLPrnt As DWORD
MEMBER DLLPassword As DWORD
MEMBER DLLComment As DWORD
MEMBER DLLService As DWORD
ENDSTRUCT

STRUCT oZpopt
MEMBER fSuffix As DWORD
MEMBER fEncrypt As DWORD
MEMBER fSystem As DWORD
MEMBER fVolume As DWORD
MEMBER fExtra As DWORD
MEMBER fNoDirEntries As DWORD
MEMBER fExcludeDate As DWORD
MEMBER fIncludeDate As DWORD
MEMBER fVerbose As DWORD
MEMBER fQuiet As DWORD
MEMBER fCRLF_LF As DWORD
MEMBER fLF_CRLF As DWORD
MEMBER fJunkDir As DWORD
MEMBER fRecurse As DWORD
MEMBER fGrow As DWORD
MEMBER fForce As DWORD
MEMBER fMove As DWORD
MEMBER fDeleteEntries As DWORD
MEMBER fUpdate As DWORD
MEMBER fFreshen As DWORD
MEMBER fJunkSFX As DWORD
MEMBER fLatestTime As DWORD
MEMBER fComment As DWORD
MEMBER fOffsets As DWORD
MEMBER fPrivilege As DWORD
MEMBER fEncryption As DWORD
MEMBER fRepair As DWORD
MEMBER flevel As DWORD
MEMBER date As STRING LEN 10
MEMBER szRootDir As STRING LEN 100
ENDSTRUCT

STRUCT oZipNames
MEMBER S As STRING
ENDSTRUCT


msginfo (ZpInit())
msginfo (ZpSetOptions())
msginfo (ZpArchive(1,"test.zip",{"test.obj"}))
Return (nil)

// Declaración de DLL32

DLL32 Function ZpInit (@oZipFun AS oZipUserFunctions) As DWORD PASCAL LIB "zip32.dll"
DLL32 Function ZpSetOptions (@oOpts AS oZpOpt) As DWORD PASCAL LIB "zip32.dll"
DLL32 Function ZpArchive (@nArgc AS DWORD,;
@cFuName AS STRING,;
@oArgV AS oZipNames) As DWORD PASCAL LIB "zip32.dll"
--------------------------------------------------------
bueno, tras esto la funcion zpinit y la funcion zpsetoptions se ejecutan sin problemas pero la zparchive me da un error harbour exception error, y supongo que habre definido mal alguno de los parámetros, pero ya os digo que ando muy verde ....
Alguien con experiencia puede hecharme una mano???

Gracias.

Posted: Sun May 21, 2006 5:46 pm
by Antonio Linares
Angel,

En vez de:
DLL32 Function ZpInit (@oZipFun AS oZipUserFunctions) ...

usa:
DLL Function ZpInit (oZipFun AS LPSTR) ...

y antes de llamarla haces:
local cBuffer := oZipUserFunctions:cBuffer
ZpInit( cBuffer )
oZipUserFunctions:cBuffer = cBuffer

igual con la otra

Posted: Sun May 21, 2006 6:51 pm
by AngelSalom
Gracias por tu pronta respuesta, Antonio.
Pero parece que no va por ahi la cosa.
El tema es que creo que le tengo que pasar de alguna manera toda la estructura, porque de esta forma tan solo le paso un valor y sigue "petando" el programita.

STRUCT oZipUserFunctions
MEMBER DLLPrnt As DWORD
MEMBER DLLPassword As DWORD
MEMBER DLLComment As DWORD
MEMBER DLLService As DWORD
ENDSTRUCT

Fijate que la oZipUserFunctions tiene varias variables y no se como narices pasarlo para que no reviente.

Gracias.

Posted: Sun May 21, 2006 7:35 pm
by AngelSalom
Vaaaaaale, creo que lo voy pillando.
De la forma que me has dicho las dos primeras funciones van correctamente :

cBuffer:=oZipUserFunctions:cBuffer
msginfo (ZpInit (cBuffer))
oZipUserFunctions:cBuffer=cBuffer

cBuffer:=oZPopt:cBuffer
msginfo (ZpInit (cBuffer))
oZPopt:cBuffer=cBuffer

Pero en la funcion ZpArchive es donde peta y yo creo que es porque no se como declarar en la STRUCT oZipNames el formato del campo, en VisualBasic aparece asi :

Public Type ZIPnames
s(0 To 99) As String
End Type

Sabes como puedo traducirlo correctamente????

Gracias.

Posted: Sun May 21, 2006 10:23 pm
by Antonio Linares
Angel,

> s(0 To 99) As String

Eso parece un array de cadenas. De ser así, se podría declarar como:

MEMBER s1 AS LPSTR
MEMBER s2 AS LPSTR
MEMBER s3 AS LPSTR
...

así hasta 100.

Hay que confirmar que s(0 To 99) signifique eso. Igual quiere decir que es una cadena de 100 bytes, en cuyo caso, sería:

MEMBER s AS STRING LEN 100

Es un array

Posted: Mon May 22, 2006 2:02 am
by fleal
Public Type ZIPnames
s(0 To 99) As String
End Type


s(0 To 99) As String

Es un array .NET usado en Visual Basic 2005. En Visual Basic 6 el indice inferior es 1, en la versión de VB 2005 el indice inferior es 0, por lo tanto indica valores de 0 a 99 dando un total de 100 elementos.

Saludos
Fernando Leal

Posted: Mon May 22, 2006 5:49 am
by AngelSalom
Naaada, que no hay forma.
Probaré con otra DLL a ver si tengo más suerte.

Ya os contare.
Un saludo.

Posted: Mon May 22, 2006 8:33 am
by Antonio Linares
Angel,

Si no consigues hacerlo funcionar desde PRG, entonces la solución es escribir la función en C directamente.

Posted: Mon May 22, 2006 4:50 pm
by RuFer
Angel:

Disculpa me entrometa en lo que estas haciendo:

Hay una utilidad hecha en xHarbour que se llama
xBLite y viene con PRG y todo, quizás sea mas
facil pasar esta a Harbour.

Esta muy completa, yo no la uso porque intente pasarla
a Harbour y realmente no pude.

Saludos.

Ruben Fernandez.

Posted: Mon May 22, 2006 5:00 pm
by AngelSalom
Te agradeceria que me indicaras desde donde descargarla, gracias.

Posted: Mon May 22, 2006 5:40 pm
by karinha
AngelSalom wrote:Te agradeceria que me indicaras desde donde descargarla, gracias.

http://busca.uol.com.br/www/index.html? ... backuplite