STAGE_RC create_operation::stage() { auto file_manager = config_.file_manager; const path_t destination(get_destination()); const path_t destination_dir(destination.parent_path()); if (config_.verbose) { indent(); debug() << "Caching path: "<< cache_path_; debug() << "Destination path: " << destination; deindent(); } // Prepare our staging directory if (!file_manager->ensure_directory(cache_dir_)) { error() << "Unable to create caching directory: " << cache_dir_; return STAGE_UNAUTHORIZED; } // Prepare our destination directory, if necessary if (!file_manager->ensure_directory(destination_dir)) { error() << "Unable to create destination dir: " << destination_dir; return STAGE_UNAUTHORIZED; } // Make sure the destination is free if (file_manager->is_readable(destination) && !marked_for_deletion_) { error() << "Destination is occupied!"; return STAGE_FILE_EXISTS; } // Can we write to the destination? if (!file_manager->is_writable(destination)) { error() << "Destination isn't writable!"; return STAGE_UNAUTHORIZED; } // Can we write to the staging destination? if (!file_manager->is_writable(cache_path_)) { error() << "The cache isn't writable: " << cache_path_; return STAGE_UNAUTHORIZED; } if (!config_.downloader->fetch(src_uri, cache_path_, src_checksum)) { throw invalid_resource(src_uri); } return STAGE_OK; }
void CodeGenerator::generateCode(std::ostream *os_) { os = os_; emitLine(std::string("#include \"node.h\"")); emitLine(std::string("#include \"stltree.h\"")); emitLine(std::string("")); emitLine(std::string("void stltree_create(stltree *t) {")); indent(); ast->root->codeGen(*this); emitLine(std::string("t->root = n") + ast->root->id() + std::string(";")); deindent(); emitLine(std::string("}")); }