public function testGetFolderPath()
 {
     // We first get the base path
     $base = filemanager_helpers_FileUtils::getBasePath();
     $filePath = $base . 'Animals/puss-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath);
     $this->assertEquals($folderPath, '/Animals/');
     // It does not exist!
     $filePath = $base . 'Animals/hippo-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath);
     $this->assertNull($folderPath);
     $base = 'C:\\wamp3\\www\\taotrunk\\filemanager\\views\\data\\';
     $filePath = $base . 'Animals/chicken.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath, $base, false);
     $this->assertEquals($folderPath, '/Animals/');
     // Test a linux like test.
     $base = '/var/www/taoinstall/filemanager/views/data/';
     $filePath = $base . 'Animals/puss-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath, $base, false);
     $this->assertEquals($folderPath, '/Animals/');
     $filePath = $base . 'puss-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath, $base, false);
     $this->assertEquals($folderPath, '/');
 }
 /**
  * delete the selected file or folder
  *
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  */
 public function delete()
 {
     $data = array('deleted' => false);
     if ($this->hasRequestParameter('file')) {
         $file = urldecode($this->getRequestParameter('file'));
         if (tao_helpers_File::securityCheck($file, true)) {
             $data['deleted'] = unlink(filemanager_helpers_FileUtils::cleanConcat(array(filemanager_helpers_FileUtils::getBasePath(), $file)));
         }
     }
     if ($this->hasRequestParameter("folder")) {
         $folder = urldecode($this->getRequestParameter('folder'));
         if (tao_helpers_File::securityCheck($folder, true)) {
             if (filemanager_helpers_FileUtils::deleteFolder(filemanager_helpers_FileUtils::cleanConcat(array(filemanager_helpers_FileUtils::getBasePath(), $folder)), true)) {
                 $data['deleted'] = true;
             }
         }
     }
     echo json_encode($data);
 }