Skip to content

classes_modules_uploads_wdffolderarchive.class

Daniel Spors edited this page Dec 19, 2023 · 1 revision

Classes in file modules/uploads/wdffolderarchive.class.php

class WdfFolderArchive

Represents a monitored/archived folder. This class automatically monitors the given folder for files and creates an archive for them. Note that this will need you to install 7-zip manually in the system: https://www.7-zip.org/download.html

add

Adds contents to the archive. This will first create (or overwrite) a file locally on disk and then add it to the archive.

Definition: public function add($path_inside_archive, $content, $keep_local=false)

Returns: bool True if the file was added, false otherwise.

Parameters:

  • mixed $path_inside_archive File-path inside the archive.

  • mixed $content File contents.

  • mixed $keep_local If false, the temporary file will be removed from the disk.

archiveExists

Checks if the archive file exists.

Definition: public function archiveExists()

Returns: bool True if the archive file exists, false otherwise

bool

Walks files in the archive. The flags $present_in_archive and $not_present_in_archive can be used to filter the files.

Definition: public function bool($present_in_archive, bool $present_local, $callback, $force_local_scan=false)

Returns: void

Parameters:

  • bool $present_in_archive File must be present in the archive.

  • bool $present_local File must be present on disk.

  • mixed $callback Callback to be called for each file. If it returns FALSE, processing is aborted.

  • mixed $force_local_scan If true, buffer is skipped and local files are (re-)scanned.

contains

Checks if a path exists inside the archive.

Definition: public function contains($path_inside_archive)

Returns: bool True if the path exists, false otherwise

Parameters:

  • mixed $path_inside_archive Path inside the archive

CreateFromBaseFolder

Creates an archive for each folder in the given base folder. Note that this will be the folder where the archive will be saved.

Definition: public static function CreateFromBaseFolder($folder)

Returns: array Created archives

Parameters:

  • mixed $folder Base folder

delete

Removes a file or folder from the archive.

Definition: public function delete($path_inside_archive)

Returns: array Array of file paths that were removed.

Parameters:

  • string $path_inside_archive Path inside the archive.

false

Lists all files in the archive.

Definition: public function false($callback)

Returns: array Array of files. If callback is used, will always be empty.

Parameters:

  • mixed $callback Optional callback for each file. If it returns false, processinf is aborted

get

Returns file contents from the archive.

Definition: public function get($path_inside_archive)

Returns: mixed File contents or NULL

Parameters:

  • mixed $path_inside_archive File path inside the archive.

removeEmptyLocalFolders

Removes all empty folders in the monitored folder.

Definition: public function removeEmptyLocalFolders()

Returns: void

updateAll

Rescans everything and updates the archive from disk.

Definition: public function updateAll()

Returns: array Array of files that have been added or updated.

updateFile

Updates a file inside the archive from disk.

Definition: public function updateFile($path_inside_archive)

Returns: bool True if the file was updated, false otherwise.

Parameters:

  • mixed $path_inside_archive Path inside the archive.

updateFolder

Updates a folder in the archive.

Definition: public function updateFolder($path_inside_archive)

Returns: array Array of updated files

Parameters:

  • mixed $path_inside_archive Path inside the archive
Clone this wiki locally