Exemple #1
0
 public function createGroup($scope, $path)
 {
     xapp_import('xapp.Directory.Utils');
     xapp_import('xapp.Path.Utils');
     xapp_import('xapp.VFS.Local');
     xapp_import('xapp.Commons.Exceptions');
     $fullPath = $this->resolvePath($scope, $path, null, true, false);
     xapp_clog('create driver group : ' . $fullPath . ' for scope ' . $scope . ' and path ' . $path);
     return XApp_File_Utils::mkDir(XApp_Path_Utils::securePath($fullPath));
 }
Exemple #2
0
 function mkDir($mount, $relativePath)
 {
     return XApp_File_Utils::mkDir(XApp_Path_Utils::securePath(self::toAbsolutePath($mount) . DIRECTORY_SEPARATOR . $relativePath));
 }
Exemple #3
0
 public function ls($mount = 'ws', $path = '/', $options = null)
 {
     xapp_import('xapp.Xapp.Hook');
     $recursive = false;
     //sanitize
     $basePath = XApp_Path_Utils::normalizePath($mount, false, false);
     if ($basePath === '' || $basePath === '.') {
         $basePath = 'root';
     }
     $path = XApp_Path_Utils::normalizePath($path, false, false);
     $options = (array) $options;
     $scanPath = $basePath . DIRECTORY_SEPARATOR . $path;
     $scanPath = XApp_Path_Utils::normalizePath($scanPath, false, false);
     $vfs = $this->getFileSystem($scanPath);
     //defaults
     if (!$options) {
         $options = array(XApp_File_Utils::OPTION_DIR_LIST_FIELDS => XAPP_XFILE_SHOW_SIZE | XAPP_XFILE_SHOW_PERMISSIONS | XAPP_XFILE_SHOW_ISREADONLY | XAPP_XFILE_SHOW_ISDIR | XAPP_XFILE_SHOW_OWNER | XAPP_XFILE_SHOW_TIME | XAPP_XFILE_SHOW_MIME);
     }
     //hook into meta data creation for custom completion
     Xapp_Hook::connect(XApp_VFS_Base::EVENT_ON_NODE_META_CREATED, $this, "_onItem", '', array('parentPath' => $path, 'mount' => $basePath, 'remote' => $vfs->remote, 'options' => $options));
     //hook into 'node add' for custom node rejection
     Xapp_Hook::connect(XApp_VFS_Base::EVENT_ON_NODE_ADD, $this, "_addNode", '', array('mount' => $basePath, 'owner' => $this, 'options' => $options, 'remote' => $vfs->remote));
     $result = null;
     try {
         $vfs->ls(XApp_Path_Utils::normalizePath($scanPath, false), $recursive, $options);
     } catch (Exception $e) {
         return $this->toRPCError(1, $e->getMessage());
     }
     //prepare root object
     $rootObject = new stdClass();
     $fullPath = $vfs->toRealPath($basePath);
     if (!file_exists($fullPath)) {
         xapp_import('xapp.File.Utils');
         $res = XApp_File_Utils::mkDir($fullPath, 0755, true);
         if ($res == false) {
             return $this->toRPCError(1, 'Sorry, couldnt create directory');
         }
     }
     $vfs->add_ls_file_information($vfs->toRealPath($basePath), $rootObject, XAPP_XFILE_SHOW_SIZE | XAPP_XFILE_SHOW_PERMISSIONS | XAPP_XFILE_SHOW_ISREADONLY | XAPP_XFILE_SHOW_TIME | XAPP_XFILE_SHOW_MIME);
     //corrections
     $rootName = '' . $path;
     $rootPath = '' . $path;
     if ($rootName === '' || $rootName === '/') {
         $rootName = '.';
     }
     if ($rootPath === '' || $rootPath === '/') {
         $rootPath = '.';
     } else {
         $rootPath = './' . $path;
     }
     $rootPath = str_replace('//', '/', $rootPath);
     if ($this->isWindows()) {
         //whatever
         $rootPath = str_replace('././', './', $rootName);
     }
     $rootName = basename($rootName);
     $rootName = str_replace('/', '', $rootName);
     //prepare Dojo store root structure
     $result = array('status' => 200, 'total' => 1, 'items' => array());
     $result['items'][] = array('children' => $this->_currentItems, '_EX' => true, 'size' => 0, 'name' => $rootName, 'path' => $rootPath, 'mount' => $basePath, 'directory' => true);
     return $result;
 }