Exemplo n.º 1
0
void ClientState::restoreGlobalState(const FilePath& stateFile)
{
   if (stateFile.extension() == kTemporaryExt)
      restoreState(stateFile, &temporaryState_);
   else if (stateFile.extension() == kPersistentExt)
      restoreState(stateFile, &persistentState_);
}
Exemplo n.º 2
0
std::string provision(const std::string& title, const FilePath& filePath)
{
    // calculate content path
    std::string contentFile = core::system::generateUuid(false) +
                              filePath.extension();
    FilePath contentPath = contentUrlPath().complete(contentFile);

    // copy the file
    Error error = filePath.copy(contentPath);
    if (error)
        LOG_ERROR(error);

    // calculate and return content url
    return buildContentUrl(title, contentFile);
}
Exemplo n.º 3
0
SEXP rs_pathInfo(SEXP pathSEXP)
{
   try
   {
      // validate
      if (r::sexp::length(pathSEXP) != 1)
      {
         throw r::exec::RErrorException(
                        "must pass a single file to get path info for");
      }

      std::string path;
      Error error = r::sexp::extract(pathSEXP, &path);
      if (error)
         throw r::exec::RErrorException(r::endUserErrorMessage(error));

      // resolve aliased path
      FilePath filePath = module_context::resolveAliasedPath(path);
      if (filePath.empty())
         throw r::exec::RErrorException("invalid path: " + path);

      // create path info vector (use json repsesentation to force convertion
      // to VECSXP rather than STRSXP)
      json::Object pathInfo;
      pathInfo["path"] = filePath.absolutePath();
      std::string parent = filePath.absolutePath();
      FilePath parentPath = filePath.parent();
      if (!parentPath.empty())
         parent = parentPath.absolutePath();
      pathInfo["directory"] = parent;
      pathInfo["name"] = filePath.filename();
      pathInfo["stem"] = filePath.stem();
      pathInfo["extension"] = filePath.extension();

      // return it
      r::sexp::Protect rProtect;
      return r::sexp::create(pathInfo, &rProtect);
   }
   catch(r::exec::RErrorException e)
   {
      r::exec::error(e.message());
   }
   CATCH_UNEXPECTED_EXCEPTION

   return R_NilValue;
}
Exemplo n.º 4
0
void ClientState::restoreProjectState(const FilePath& stateFile)
{
   if (stateFile.extension() == kProjPersistentExt)
      restoreState(stateFile, &projectPersistentState_);
}