View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006255||JEDI VCL||00 JVCL Components||public||2014-02-28 20:05||2014-09-03 11:32|
|Product Version||Daily / GIT|
|Target Version||Fixed in Version|
|Summary||0006255: Change TJvCABFile.ExtractFile to allow filename override|
|Description||The current implementation of TJvCABFile.ExtractFile extracts a file into the destination path using the same relative path and name of the file in the CAB. I am requesting that ExtractFile be changed (or overloaded) to allow a filename override such that the file can be extracted to a specific path and different name regardless of the original.|
- CAB file contains file "Path\SubPath\file.ext"
- invoke ExtractFile('Path\SubPath\file.ext', 'C:\dest')
- Assuming the directories exist the following file will be created:
However, what if the desired result is for the file to be named "C:\dest\file.ext" or "C:\dest\newfile.newext"? Currently, the only solution is to allow the file to be extracted to the full path and then moved to the new path and name. This isn't hard but it requires extra work and might not always be possible. Since the CAB extraction API already supports this functionality I think it would be nice if TJvCABFile can support it.
|Additional Information||I modified the source to do what I am requesting. The full file with all modifications is attached. Here is an overview of the changes I made:|
I added a variable 'FDestFileName', overloaded ExtractFile, and modified CExtract to use FDestFileName if present.
// Added private variable
// Overloaded ExtractFile
function ExtractFile(FileName: string; DestPath: string): Boolean; overload;
function ExtractFile(FileName, DestPath, DestFileName: string): Boolean; overload;
// line 220: function CExtract. Inserted the following code before Path := Sender.FDestPath;
if Length(Sender.FDestFileName) > 0 then
Path := Sender.FDestFileName
// Added new ExtractFile method
function TJvCABFile.ExtractFile(FileName, DestPath, DestFileName: string): Boolean;
if DestPath[Length(DestPath)] <> PathDelim then
DestPath := DestPath + PathDelim;
FDestFileName := DestPath + DestFileName;
Result := ExtractFile(FileName, DestPath);
FDestFileName := ''; // clean up
An alternate approach would be to modify TOnExtractFile to make the FileName argument "var". The downside of this approach is that any existing event handler code would have the wrong signature.
|Tags||No tags attached.|