public function set_comment($zip_file, $comment) { $result = false; $za = NULL; // This should give us a new archive object, of not catch it and bail out try { $za = new pluginbuddy_PclZip($zip_file); $result = true; } catch (Exception $e) { // Something fishy - the methods indicated pclzip but we couldn't find the class $error_string = $e->getMessage(); pb_backupbuddy::status('details', sprintf(__('pclzip indicated as available method but error reported: %1$s', 'it-l10n-backupbuddy'), $error_string)); $result = false; } // Only continue if we have a valid archive object if (true === $result) { // Make sure we opened the zip ok and we added the comment ok // Note: using empty array as we don't actually want to add any files if (0 !== ($list = $za->add(array(), PCLZIP_OPT_COMMENT, $comment))) { // We got a list back so adding comment should have been successful pb_backupbuddy::status('details', sprintf(__('PclZip set comment in file %1$s', 'it-l10n-backupbuddy'), $zip_file)); $result = true; } else { // If we failed to set the commnent then log it (?) and drop through $error_string = $za->errorInfo(true); pb_backupbuddy::status('details', sprintf(__('PclZip failed to set comment in file %1$s - Error Info: %2$s', 'it-l10n-backupbuddy'), $zip_file, $error_string)); $result = false; } } if (NULL != $za) { unset($za); } return $result; }