Change content of a zip file with Abbrevia - delphi

I have a existing zip archive and want to change a file which is already in the zipfile. Furthermore I want to add an file to the existing zip archive. I tried with TZipFile but it doesn't offer the required functionality. But Abbrevia should be able to but I don't know how.
coZip := TAbZipper.Create(nil);
coZip.OpenArchive(ContainerFileName);
coZip.ChangeFile(xxx); // What to do here? ChangeFile or similar function does not exist
coZip.AddFiles("NewFile.txt");
Any suggestions how to do that?

Related

Manually re-compress an unzipped system.iopackage to a working Excel file

System.IO.Packaging is easy to work with because the resulting files are ZIPped folders, so you can simply rename the file to .zip and then open it. I do this with XLSX files to see how they are built.
Unfortunately, the reverse is not true; if you re-compress the folder and rename it .XLSX, Excel with say it has unreadable content. This is true even if the file is unchanged. If you simply rename, extract all, recompress, rename, the resulting file does not work.
Poking about inside, it seems the format of the file is not a canonical zip, header information is missing?
Anyone know an easy trick to recompress these files in Explorer? It would be nice to be able to test changes.

Delphi .proj file missing .dpk file

I recently got project in delphi which I need to rearange, I'm totally new in delphi so I'm searching my way in environment and language. Question, in my project group I have two files with .dproj extension, no corresponding .dpr file so when I try to load them I got msg:
"Canot open file xxxx.dpk, system cannot find the file specified"
Did the old programmer forgot to copy all files so I'm missing this, or is this some kind of file (.dproj) that I only add as a reference so I don't need to have corresponding .dpk or .dpr file??
The .dpk file is the top level Pascal source file for a package. It is the package equivalent of an application project's .dpr file.
The original developer should have supplied it to you. Ask them to do so.

Save multiple files as one package with custom file type

I need to save multiple files as one custom file, which then can be exported and imported into the iOS app. The files that go into this package are PDFs and TXTs.
A .pages file on the Mac is pretty much exactly what I want, it is a package which contains the original files, but acts as a custom (Pages) file.
I looked into NSFileWrapper, NSKeyedArchiver and NSFileManager, but I can't find the right way to solve this problem. How can I export multiple files into one package on iOS, that I can save with my own file extension and where I can easily get the original files out when importing?

Remove a file from a ZIP archive using JclCompression in Delphi XE2

I've got this situation where I need to remove a specific file from a ZIP archive. Within the application all handling of ZIP files is done using JclCompression. I was wondering if any of you know how to remove a specific file from a ZIP archive using JclCompression? (I couldn't find it)
So, I just accidentally ran into the solution:
Besides the TJclZipCompressionArchive and TJclDecompressionArchive the JclCompression library also provides a TJclZipUpdateArchive class. This class contains a method to remove a file from the archive.
zip.RemoveItem(PackedName);

Delphi .PAS code reverts to the previous code after compile/build

I have a .BPG project which has a collection of .DPR project files.
Opened a .PAS file
I changed some line of code in a .PAS file of an project.
Saved it
After changing the source code, I tried COMPILE on that project.
First it says "Compiled" successfully.
Now I see the same .PAS file, the changes were lost. Codes changed at step 2 was lost. It is having the previous code only.
The behavior is same for BUILD too.
Anyone knows about this problem?
Thanks in advance.
Update
One more hint:
.DPR Project Name is XX.dll In IDE, there is one file with name XX_TLB.PAS in that project. In this file only I tried to change some code, which got reverted after compiling/building. Now I tried to rename this file, which gave me a error message
Type Libraries must have the tlb extention.
Also can the .DCU and .PAS files be in the same directory? I entered this directory (where both .PAS and .DCU files exist) into the directories list under "Tools->Options->Delphi Options->Library - Win32"
XX_TLB.PAS files are protected files. Do not edit such files directly. In fact there is note on top of the file warning you from editing the file.
They are regenerated each time the type library is refreshed.
See Code Generated When You Import Type Library Information.
This refresh could be done by the IDE each time you compile/build your dll.
You will never edit this file because of the dependencies of a type library and registered com objects. Either you change the com object itself via the type library editor, or create a new unit that interacts with your ActiveX class.
The Delphi IDE doesn't undo changes, as a general rule. There's notable exception. When you create an empty event handler, and then save the source file, the IDE will remove that event handler. Perhaps that's what is happening.
The other possibility that occurs to me is that you have multiple copies of the file. I've known the following to happen:
You create a package containing Unit1.
You install the package.
You then make another project that contains a different Unit1. Perhaps a copy of the file in a different location, so that it looks like the same unit.
You then modify the copy of Unit1, but the IDE sometimes prefers to open the file from the package.
The bottom line is that beyond deleting empty event handlers the IDE won't undo your changes. So it seems extremely likely that you have multiple copies of the file. To get to the bottom of this, you need to get the full path to the file. In the IDE, hover over the tab with the filename and the IDE will display the full path in a hint. I suspect you'll find that you have two distinct files.

Resources