Set special folder associations stored in storage backend
439445
public function set_special_folders($specials)
    {
        if (!$this->get_capability('SPECIAL-USE') || !$this->get_capability('METADATA')) {
            return false;
        }

        if (!$this->check_connection()) {
            return false;
        }

        $folders = $this->get_special_folders(true);
        $old     = (array) $this->icache['special-use'];

        foreach ($specials as $type => $folder) {
            if (in_array($type, rcube_storage::$folder_types)) {
                $old_folder = $old[$type];
                if ($old_folder !== $folder) {
                    // unset old-folder metadata
                    if ($old_folder !== null) {
                        $this->delete_metadata($old_folder, array('/private/specialuse'));
                    }
                    // set new folder metadata
                    if ($folder) {
                        $this->set_metadata($folder, array('/private/specialuse' => "\\" . ucfirst($type)));
                    }
                }
            }
        }

        $this->icache['special-use'] = $specials;
        unset($this->icache['special-folders']);

        return true;
    }
701072
def _ensure_folder_path(self, filebase_path):
        """"""
        folders = filebase_path.split('/')
        parent = {"id": "root"}
        for folder in folders:
            file_list = self.drive.ListFile(
                {'q': "'{}' in parents and trashed=false and title = '{}'".format(
                    parent['id'], folder)}).GetList()
            if not len(file_list):
                f = self.drive.CreateFile({'title': folder, 'parents': [parent],
                                           'mimeType': 'application/vnd.google-apps.folder'})
                f.Upload()
            else:
                parent = {"id": file_list[-1]["id"]}
        return parent
388306
def setStoragePath(self, location, path):
        
        if not path:
            self._storagePaths.pop(location, None)
        else:
            self._storagePaths[location] = path
858778
def put_file_range(ase, offsets, data, timeout=None):
    # type: (blobxfer.models.azure.StorageEntity,
    #        blobxfer.models.upload.Offsets, bytes, int) -> None
    
    dir, fpath, _ = parse_file_path(ase.name)
    ase.client.update_range(
        share_name=ase.container,
        directory_name=dir,
        file_name=fpath,
        data=data,
        start_range=offsets.range_start,
        end_range=offsets.range_end,
        validate_content=False,  # integrity is enforced with HTTPS
        timeout=timeout)
703316
def txn_storeAssociation(self, server_url, association):
        
        a = association
        self.db_set_assoc(
            server_url,
            a.handle,
            self.blobEncode(a.secret),
            a.issued,
            a.lifetime,
            a.assoc_type)
1188007
def ensure_storage_format(root_dir):
    
    if not os.path.isdir(os.path.join(root_dir, 'blobs')):
        print('"blobs/" directory not found')
        sys.exit(1)

    if not os.path.isdir(os.path.join(root_dir, 'links')):
        print('"links/" directory not found')
        sys.exit(1)

    if not os.path.isdir(os.path.join(root_dir, 'db')):
        print('"db/" directory not found')
        sys.exit(1)
168884
def set_file_properties(ase, md5, timeout=None):
    # type: (blobxfer.models.azure.StorageEntity, str, int) -> None
    
    dir, fpath, _ = parse_file_path(ase.name)
    ase.client.set_file_properties(
        share_name=ase.container,
        directory_name=dir,
        file_name=fpath,
        content_settings=azure.storage.file.models.ContentSettings(
            content_type=blobxfer.util.get_mime_type(fpath),
            content_md5=md5,
            cache_control=ase.cache_control,
        ),
        timeout=timeout)
825072
def prepare_storage_dir(storage_directory):
    """"""
    storage_directory = os.path.expanduser(storage_directory)
    if not os.path.exists(storage_directory):
        os.mkdir(storage_directory)

    return storage_directory
373413
protected void setStorageType(Properties props, StorageDirectory sd)
      throws InconsistentFSStateException {
    NodeType type = NodeType.valueOf(getProperty(props, sd, STORAGE_TYPE));
    if (!storageType.equals(type)) {
      throw new InconsistentFSStateException(sd.root,
          "node type is incompatible with others.");
    }
    storageType = type;
  }
208152
function(location, name) {
  this.location = location;
  this.name = name;
  if (typeof localStorage === 'undefined' || localStorage === null) {
    if (this.name) {
      this.name = require('sanitize-filename')(this.name, {replacement: '_'});
      require('mkdirp').sync(this.location);
    }
  }
  else {
    this.localStorage = localStorage;
  }
  this.path = this.location;
  if (this.name)
    this.path += '/' + this.name;
}
58221
function _ensureFoldersExist() {
  _ensureFoldersExist = (0, _asyncToGenerator2["default"])(
  /*#__PURE__*/
  _regenerator["default"].mark(function _callee5(channelName, paths) {
    var chmodValue;
    return _regenerator["default"].wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            paths = paths || getPaths(channelName);
            _context5.next = 3;
            return ensureBaseFolderExists();

          case 3:
            _context5.next = 5;
            return mkdir(paths.channelBase)["catch"](function () {
              return null;
            });

          case 5:
            _context5.next = 7;
            return Promise.all([mkdir(paths.readers)["catch"](function () {
              return null;
            }), mkdir(paths.messages)["catch"](function () {
              return null;
            })]);

          case 7:
            // set permissions so other users can use the same channel
            chmodValue = '777';
            _context5.next = 10;
            return Promise.all([chmod(paths.channelBase, chmodValue), chmod(paths.readers, chmodValue), chmod(paths.messages, chmodValue)])["catch"](function () {
              return null;
            });

          case 10:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _ensureFoldersExist.apply(this, arguments);
}
411571
function fileStoreContents( $filePath, $contents, $scope = false, $datatype = false )
    {
        eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileStoreContents( '$filePath' )", __METHOD__ );

        eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );

        eZFile::create( basename( $filePath ), dirname( $filePath ), $contents, true );

        $perm = eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' );
        chmod( $filePath, octdec( $perm ) );

        eZDebug::accumulatorStop( 'dbfile' );
    }
767502
def create_backend(name: str=None, git_index: GitIndex=None, args: str=None) -> StorageBackend:
    """"""
    if name is None:
        name = config.BACKEND
    if not args:
        args = config.BACKEND_ARGS
    if args:
        try:
            kwargs = dict(p.split("=") for p in args.split(","))
        except:  # flake8: noqa
            raise ValueError("Invalid args") from None
    else:
        kwargs = {}
    if git_index is None:
        git_index = GitIndex()
    kwargs["index"] = git_index
    return __registry__[name](**kwargs)
435167
def initialize(self):
        """"""
        if self.collname not in self.current_kv_names():
            r = self.request('post',
                             self.url+"storage/collections/config",
                             headers={'content-type': 'application/json'},
                             data={'name': self.collname})
            r.raise_for_status()
        # initialize schema
        re = self.request('post',
                          self.url+"storage/collections/config/"+self.collname,
                          headers = {'content-type': 'application/json'},
                          data=self.schema)
        re.raise_for_status()
        logger.info("initialized Splunk Key Value Collection %s with schema %s"\
                        % (self.collname, str(self.schema)))
        if self.collname not in self.current_kv_names():
            raise EnvironmentError('expected %s in list of kv collections %s' % (self.collname, str(self.current_kv_names())))
833720
def _objectify(items, container_name):
    """"""
    objects = []

    # Deal with objects and object pseudo-folders first, save subdirs for later
    for item in items:
        if item.get("subdir", None) is not None:
            object_cls = PseudoFolder
        else:
            object_cls = StorageObject

        objects.append(object_cls(item, container_name))

    return objects
712776
def get_special_folder_by_name name
      url = base_api_url + "/me/drive/special/#{name}"
      @special_drive = JSON.parse(HTTParty.get(url,headers: set_headers).body)
    end
1331770
def modify_folder_grant(
        self,
        folder_ids,
        perm,
        zid=None,
        grantee_name=None,
        gt='usr',
        flags=None
    ):
        
        f_ids = self._return_comma_list(folder_ids)

        params = {'action': {
            'id': f_ids,
            'op': 'grant',
            'grant': {'perm': perm, 'gt': gt}
        }}

        if perm == 'none':
            params['action']['op'] = '!grant'
            params['action']['zid'] = zid
            # Remove key to raise Zimsoap exception if no zid provided
            if not zid:
                params['action'].pop('zid', None)

        if grantee_name:
            params['action']['grant']['d'] = grantee_name
        elif zid:
            params['action']['grant']['zid'] = zid
        else:
            raise TypeError('missing zid or grantee_name')

        self.request('FolderAction', params)