Creates the top-level (system) bookmark state directory, then the user's
bookmark state directory, and then the app's bookmark state directory.
491194
function createBookmarkStateDirectory_p(bookmarkStateDir, username) {
  if (bookmarkStateDir === null || bookmarkStateDir === "") {
    return Q();
  }

  // Capitalize first character
  function capFirst(str) {
    return str.charAt(0).toUpperCase() + str.slice(1);
  }

  function createDir_p(dir, mode, username, label) {
    if (label) {
      label = label + ' ';
    } else {
      label = '';
    }

    return Q.nfcall(fs.mkdir, dir, mode)
    .then(function() {
      logger.info(
        capFirst('created ' + label + 'bookmark state directory: ' + dir)
      );
    })
    .then(function() {
      // chown if username was supplied
      if (typeof(username) === 'string') {
        var pw = posix.getpwnam(username);
        return Q.nfcall(fs.chown, dir, pw.uid, pw.gid);
      }
    })
    .fail(function(err) {
      return Q.nfcall(fs.stat, dir)
      .then(function(stat) {
        if (!stat.isDirectory()) {
          logger.error(
            capFirst(label + 'bookmark state directory existed, was a file: ' + dir)
          );
          throw err;
        }
      })
      .fail(function(err2) {
        logger.error(
          capFirst(label + 'bookmark state directory creation failed: ' + dir)
        );
        throw err2;
      });
    });
  }

  var userBookmarkStateDir = path.join(bookmarkStateDir, username);

  return createDir_p(bookmarkStateDir, '711')
  .then(function() {
    return createDir_p(userBookmarkStateDir, '700', username, 'user');
  })
  .fail(function(err) {
    throw err;
  });
}
145106
private void initJobDir (SourceState state) throws IOException {
    String tmpBase = state.getProp(MRCompactor.COMPACTION_TMP_DEST_DIR, MRCompactor.DEFAULT_COMPACTION_TMP_DEST_DIR);
    String jobId;

    if (state instanceof JobState) {
      jobId = ((JobState) state).getJobId();
    } else {
      jobId = UUID.randomUUID().toString();
    }

    this.tmpJobDir = new Path (tmpBase, jobId);
    this.fs.mkdirs(this.tmpJobDir);
    state.setProp (MRCompactor.COMPACTION_JOB_DIR, tmpJobDir.toString());
    log.info ("Job dir is created under {}", this.tmpJobDir);
  }
477661
def add_bookmark(title, href, attributes = {}, &block)
      attributes = attributes.merge :title => title, :href => href
      add_child build(:bookmark, attributes, &block)
    end
1301574
def create_hierarchy(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinAdminSession.create_bin
        return Hierarchy(
            self._provider_manager,
            self._get_provider_session('hierarchy_admin_session').create_hierarchy(*args, **kwargs),
            self._runtime,
            self._proxy)
526728
function install()
    {
        $this->createConfigurationDirectory();
        $this->createDriversDirectory();
        $this->createSitesDirectory();
        $this->createExtensionsDirectory();
        $this->createLogDirectory();
        $this->createCertificatesDirectory();
        $this->writeBaseConfiguration();

        $this->files->chown($this->path(), user());
    }
273698
def set_up(self):
        """"""
        self.path.state = self.path.gen.joinpath("state")
        if self.path.state.exists():
            self.path.state.rmtree(ignore_errors=True)
        self.path.state.mkdir()

        if self.path.gen.joinpath("q").exists():
            self.path.gen.joinpath("q").remove()

        for filename, text in self.given.get("files", {}).items():
            filepath = self.path.state.joinpath(filename)
            if not filepath.dirname().exists():
                filepath.dirname().makedirs()
            filepath.write_text(text)

        for filename, linkto in self.given.get("symlinks", {}).items():
            filepath = self.path.state.joinpath(filename)
            linktopath = self.path.state.joinpath(linkto)
            linktopath.symlink(filepath)

        for filename, permission in self.given.get("permissions", {}).items():
            filepath = self.path.state.joinpath(filename)
            filepath.chmod(int(permission, 8))


        pylibrary = hitchbuildpy.PyLibrary(
            name="py3.5.0",
            base_python=hitchbuildpy.PyenvBuild("3.5.0").with_build_path(self.path.share),
            module_name="pathquery",
            library_src=self.path.project,
        ).with_build_path(self.path.gen)
        
        pylibrary.ensure_built()
        
        self.python = pylibrary.bin.python


        self.example_py_code = ExamplePythonCode(self.python, self.path.state)\
            .with_code(self.given.get('code', ''))\
            .with_setup_code(self.given.get('setup', ''))\
            .with_terminal_size(160, 100)\
            .with_env(TMPDIR=self.path.gen)\
            .with_long_strings(
                yaml_snippet_1=self.given.get('yaml_snippet_1'),
                yaml_snippet=self.given.get('yaml_snippet'),
                yaml_snippet_2=self.given.get('yaml_snippet_2'),
                modified_yaml_snippet=self.given.get('modified_yaml_snippet'),
            )
609214
def create_results_dir(self):
    """"""
    self._current_results_dir = self._cache_manager._results_dir_path(self.cache_key, stable=False)
    self._results_dir = self._cache_manager._results_dir_path(self.cache_key, stable=True)

    if not self.valid:
      # Clean the workspace for invalid vts.
      safe_mkdir(self._current_results_dir, clean=True)

    relative_symlink(self._current_results_dir, self._results_dir)
    self.ensure_legal()
555135
def save_state
      # start will al state to be saved
      state_to_save = { 'startup_tags' => startup_tags,
                      'reboot' => reboot?,
                      'log_level' => log_level }

      # only save a log file one is defined
      if log_file
        state_to_save['log_file'] = log_file
      end

      # only save persist the fact we downloaded cookbooks if we are in dev mode
      if download_once?
        state_to_save['has_downloaded_cookbooks'] = has_downloaded_cookbooks?
      end

      RightScale::JsonUtilities::write_json(RightScale::CookState::STATE_FILE, state_to_save)
      true
    end
1219370
protected function createDirectories()
    {
        if (! is_dir($directory = resource_path('views/layouts'))) {
            mkdir($directory, 0755, true);
        }
        if (! is_dir($directory = resource_path('views/auth'))) {
            mkdir($directory, 0755, true);
        }
        if (! is_dir($directory = resource_path('views/partials'))) {
            mkdir($directory, 0755, true);
        }
    }
1237063
private StateBackend createStateBackend() throws Exception {
		final StateBackend fromApplication = configuration.getStateBackend(getUserCodeClassLoader());

		return StateBackendLoader.fromApplicationOrConfigOrDefault(
				fromApplication,
				getEnvironment().getTaskManagerInfo().getConfiguration(),
				getUserCodeClassLoader(),
				LOG);
	}
869196
def create_base_dirs
      BASE_DIR.each do |dir|
        FileUtils.mkdir "#{@project_name}/#{dir}"
        $stdout.puts "\e[1;32m \tcreate\e[0m\t#{dir}"
      end
      FileUtils.mkdir "#{@project_name}/app/apis/#{@project_name}"
      $stdout.puts "\e[1;32m \tcreate\e[0m\tapp/apis/#{@project_name}"
    end
1290003
def create_cache_directories(self):
        """"""
        if not os.path.isdir(self.package_cache_dir):
            if not os.path.isdir(self.stacker_cache_dir):
                os.mkdir(self.stacker_cache_dir)
            os.mkdir(self.package_cache_dir)
1000102
private void installSnapshot() {
    state.checkThread();

    // If the last stored snapshot has not yet been installed and its index matches the last applied state
    // machine index, install the snapshot. This requires that the state machine see all indexes sequentially
    // even for entries that have been compacted from the log.
    Snapshot currentSnapshot = state.getSnapshotStore().currentSnapshot();
    if (currentSnapshot != null && currentSnapshot.index() > log.compactor().snapshotIndex() && currentSnapshot.index() == lastApplied && stateMachine instanceof Snapshottable) {

      // Install the snapshot in the state machine thread. Multiple threads can access snapshots, so we
      // synchronize on the snapshot object. In practice, this probably isn't even necessary and could prove
      // to be an expensive operation. Snapshots can be read concurrently with separate SnapshotReaders since
      // memory snapshots are copied to the reader and file snapshots open a separate FileBuffer for each reader.
      LOGGER.info("{} - Installing snapshot {}", state.getCluster().member().address(), currentSnapshot.index());
      executor.executor().execute(() -> {
        synchronized (currentSnapshot) {
          try (SnapshotReader reader = currentSnapshot.reader()) {
            ((Snapshottable) stateMachine).install(reader);
          }
        }
      });

      // Once a snapshot has been applied, snapshot dependent entries can be cleaned from the log.
      log.compactor().snapshotIndex(currentSnapshot.index());
    }
  }
1011305
private void createSystemDataFolder() throws IOException {
        if(!Files.exists(systemDataLocation.toPath()))
            Files.createDirectories(systemDataLocation.toPath());
    }
1105976
def initialize_directories(self):
        """"""
        makedirs(self.config.source_index)
        makedirs(self.config.eggs_cache)
397232
def _populate_setup(self):
        
        makedirs(os.path.dirname(self._cache_marker))
        with codecs.open(self._cache_marker, 'w', encoding='utf-8') as fobj:
            fobj.write(self.cache_uri)
        self.graph.open(self.cache_uri)
675436
def set_state(self, state):
        
        self.index_x.set(state[REG_X])
        self.index_y.set(state[REG_Y])

        self.user_stack_pointer.set(state[REG_U])
        self.system_stack_pointer.set(state[REG_S])

        self.program_counter.set(state[REG_PC])

        self.accu_a.set(state[REG_A])
        self.accu_b.set(state[REG_B])

        self.direct_page.set(state[REG_DP])
        self.set_cc(state[REG_CC])

        self.cycles = state["cycles"]
        self.memory.load(address=0x0000, data=state["RAM"])