Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006255 [JEDI VCL] 00 JVCL Components feature N/A 2014-02-28 20:05 2014-09-03 11:32
Reporter Zencode View Status public  
Assigned To
Priority normal Resolution open  
Status feedback   Product Version Daily / GIT
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.

Example:
- 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:
    C:\dest\Path\SubPath\file.ext

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
  FDestFileName: string;

// 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
  else

// Added new ExtractFile method
function TJvCABFile.ExtractFile(FileName, DestPath, DestFileName: string): Boolean;
begin
  if DestPath[Length(DestPath)] <> PathDelim then
    DestPath := DestPath + PathDelim;
  FDestFileName := DestPath + DestFileName;
  Result := ExtractFile(FileName, DestPath);
  FDestFileName := ''; // clean up
end;

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

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.
Attached Files ? file icon JvCabFile.pas [^] (10,036 bytes) 2014-02-28 20:05

- Relationships

-  Notes
(0021022)
obones (administrator)
2014-09-03 11:32

Please provide the zipped sources of a sample application showing the usage

- Issue History
Date Modified Username Field Change
2014-02-28 20:05 Zencode New Issue
2014-02-28 20:05 Zencode File Added: JvCabFile.pas
2014-09-03 11:32 obones Note Added: 0021022
2014-09-03 11:32 obones Status new => feedback


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker