protected function removeDirectories()
{
$file = new File();
$file->load($this->property, $this->document);
$dir = $file->getPath() . $file->getDirectory();
if (is_dir($dir)) {
$data = glob($dir . '/*');
foreach ($data as $file) {
unlink($file);
}
$tmpDir = $dir;
while ($tmpDir != GC_MEDIA_PATH . '/files') {
rmdir($tmpDir);
$tmpDir = realpath(dirname($tmpDir));
}
}
}