// if the directory for unzipped files doesn't exist yet, create the directory.
if(!file_exists($unzipdir)){
mkdir($unzipdir);
}
// Actual unzipping.
$zip = new ZipArchive;
$res = $zip->open($zipfilepath);
if($res === TRUE){
$zip->extractTo($unzipdir);
$zip->close();
}else{
drupal_set_message($message = 'The decompression was failed.', $type = 'error');
}
// If the zip file was created on the Mac platform, special directory and files will be included in the zip file. The code below will delete these directory and files.
if(file_exists($macdir_in_unzipdir)){
deleteDirectory($macdir_in_unzipdir);
}
}
/**
* Delete a specific directory.
* Delete files inside the directory, if such exist.