on_prepare_file Event
Fires for every file to be compressed before the compression starts.
Syntax
class ArchiveWriterPrepareFileEventParams(object): @property def path() -> str: ... @property def file_size() -> int: ... @property def data_source() -> int: ... @data_source.setter def data_source(value) -> None: ... @property def local_path() -> str: ... @local_path.setter def local_path(value) -> None: ... @property def action() -> int: ... @action.setter def action(value) -> None: ... # In class ArchiveWriter: @property def on_prepare_file() -> Callable[[ArchiveWriterPrepareFileEventParams], None]: ... @on_prepare_file.setter def on_prepare_file(event_hook: Callable[[ArchiveWriterPrepareFileEventParams], None]) -> None: ...
Remarks
Class fires this event for every file included in the files collection before commencing the compression. This is the last opportunity for your code to adjust the action to be taken for each file and tune up the data sources appropriately.
The Path parameter contains the path to the file within the archive (such as Photos/myphoto.jpg), and the FileSize contains the size of that file before compression.
The DataSource parameter indicates the media from which the file contents is to be taken. A typical default value if fdsFile, but you can adjust the value of that parameter if you need to use an alternative source. The following options are available:
fdsFile (0) | The data will be taken from a file indicated by the LocalPath parameter. You can change this path in this event handler. |
fdsStream (1) | The file data will be taken from a stream assigned to file_stream property. |
fdsBuffer (2) | The data will be taken from a buffer attached to the file_data property. |
The Action parameter, which is also tuneable, indicates the action for class to take on the file:
atAdd (0) | Add the file to the archive |
atKeep (1) | Keep the existing file in the archive |
atUpdate (2) | Update the archived file with a fresher copy |
atDelete (3) | Delete the file from the archive |
atExtract (4) | Extract the file (extraction only) |
atSkip (5) | Skip file extraction (extraction only) |