PDA

View Full Version : چطور از تابع های LZExpand استفاده کنم.



Ananas
یک شنبه 09 بهمن 1390, 12:54 عصر
سلام.
این LZExpand که تو ویندوز هست هم فایل هدرش و هم فایل پاسکالش تو دلفی هست چند تا تابع هم بیشتر نداره. حالا من میخوام یه فایل فشرده رو از حالت فشرده در بیارم تو هلپ یه چیزایی نوشته که اگه اشتباه نکنم باید با این توابع باشه ولی اینا فایل رو از حالت فشرده خارج نمیکنن. چطور باید UnCompress کنم؟
این نمونه کد من که فایل مثلا .pas رو بخواد از حالت فشرده که تو یه پوشه هست خارج کنه چرا نمیشه؟

var
zsrc, zdst, i : Integer;
zsBuff, zdBuff : _OFSTRUCT;
begin
zsrc := LZOpenFile('C:\test.zip', zsBuff, OF_READ);
zdst := LZOpenFile('C:\test_.pas', zdBuff, OF_CREATE);
i := LZCopy(zsrc, zdst);
LZClose(zsrc);
LZClose(zdst);
case i of
0 : ShowMessage('Ok.');
LZERROR_BADINHANDLE : ;
LZERROR_BADOUTHANDLE : ;
LZERROR_READ : ;
LZERROR_WRITE : ;
LZERROR_GLOBALLOC : ;
LZERROR_GLOBLOCK : ;
LZERROR_BADVALUE : ;
LZERROR_UNKNOWNALG : ;
end;
end;
ممنون میشم کمک کنید.

SAASTN
دوشنبه 10 بهمن 1390, 21:19 عصر
کد شما مشکلی نداره، ولی این کد تنها در صورتی فایل رو UnZip میکنه که فایل با Compress.exe فشرده شده باشه و در غیر اینصورت تنها یه کپی ساده انجام میده:
http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/94913e98-39af-46ca-970a-afc29aabbca8
اما برای UnZip کردن فایلها می تونید از ZLib استفاده کنید:
http://barnamenevis.org/showthread.php?108691-%D8%B3%D8%A7%D8%AE%D8%AA-%D9%86%D8%B1%D9%85-%D8%A7%D9%81%D8%B2%D8%A7%D8%B1-zip-%DA%A9%D9%86%D9%86%D8%AF%D9%87&highlight=%D9%81%D8%B4%D8%B1%D8%AF%D9%87%2Bzip
و البته نرم افزارهایی مثل WinRar هم امکاناتی برای استفاده از طریق CommandLine قرار دادن:
Command line syntax


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


It is possible to perform WinRAR commands from the command line. Common command line syntax is described below:

WinRAR <command> -<switch1> -<switchN> <archive> <files...> <@listfiles...> <path_to_extract\>


Command Character combination denoted function to be performed by WinRAR
Switch Switches used to define a specific type of operation, compression strength, type of archive, etc.
Archive The name of the archive to process.
Files The name(s) of files to be processed.
Listfiles Listfiles are plain text files that contain names of files to process. File names should start at the first column. It is possible to put comments to the listfile after // characters. For example, you may create backup.lst containing the following strings:
c:\work\doc\*.txt//backup text documents

c:\work\image\*.bmp//backup pictures

c:\work\misc

and then run:

winrar a backup @backup.lst

You may specify both usual file names and list files in the same command line.

Path_to_extract Used only with commands e and x, indicating the folder in which to place extracted files. If this folder does not exist, it will be created.


Notes

a) If neither files nor listfiles are specified, then *.* is implied and WinRAR will process all files;

b) If archive extension is not specified, WinRAR will use the default archive format selected in the default compression profile, but you may override it specifying either .RAR or .ZIP extension;

c) Switches entered on the command line override the same configuration settings;

d) For commands c, e, s, t, rr, k and x wildcards may be used in the archive name. Thus it is possible to process more than one archive with a single command. Moreover, if you specify -r switch with these commands, they will search for archives in subfolders;

e) Some commands and switches are applicable only to RAR archives, some both to RAR and ZIP and some to all archive formats. This is dependent upon the functionality provided by the archive format;

f) Commands and switches are not case sensitive, you may write them both in upper and in lower case.