当前位置: 首页>>代码示例>>C++>>正文


C++ DirAccess::make_dir方法代码示例

本文整理汇总了C++中DirAccess::make_dir方法的典型用法代码示例。如果您正苦于以下问题:C++ DirAccess::make_dir方法的具体用法?C++ DirAccess::make_dir怎么用?C++ DirAccess::make_dir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DirAccess的用法示例。


在下文中一共展示了DirAccess::make_dir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memnew

EditorFileSystem::EditorFileSystem() {

    reimport_on_missing_imported_files = GLOBAL_DEF("editor/reimport_missing_imported_files", true);

    singleton = this;
    filesystem = memnew(EditorFileSystemDirectory); //like, empty
    filesystem->parent = NULL;

    thread = NULL;
    scanning = false;
    importing = false;
    use_threads = true;
    thread_sources = NULL;
    new_filesystem = NULL;

    abort_scan = false;
    scanning_changes = false;
    scanning_changes_done = false;
    ResourceSaver::set_save_callback(_resource_saved);

    DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
    if (da->change_dir("res://.import") != OK) {
        da->make_dir("res://.import");
    }
    memdelete(da);

    scan_total = 0;
}
开发者ID:rrrfffrrr,项目名称:godot,代码行数:28,代码来源:editor_file_system.cpp

示例2: ok_pressed

    void ok_pressed() {

        if (!_test_path())
            return;

        String dir;

        if (mode==MODE_IMPORT) {
            dir=project_path->get_text();


        } else {
            DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);

            if (d->change_dir(project_path->get_text())!=OK) {
                error->set_text(TTR("Invalid project path (changed anything?)."));
                memdelete(d);
                return;
            }

            dir=d->get_current_dir();
            memdelete(d);

            if (mode==MODE_NEW) {




                FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE);
                if (!f) {
                    error->set_text(TTR("Couldn't create engine.cfg in project path."));
                } else {

                    f->store_line("; Engine configuration file.");
                    f->store_line("; It's best edited using the editor UI and not directly,");
                    f->store_line("; since the parameters that go here are not all obvious.");
                    f->store_line("; ");
                    f->store_line("; Format: ");
                    f->store_line(";   [section] ; section goes between []");
                    f->store_line(";   param=value ; assign values to parameters");
                    f->store_line("\n");
                    f->store_line("[application]");
                    f->store_line("\n");
                    f->store_line("name=\""+project_name->get_text()+"\"");
                    f->store_line("icon=\"res://icon.png\"");

                    memdelete(f);

                    ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons"));
                }

            } else if (mode==MODE_INSTALL) {


                FileAccess *src_f=NULL;
                zlib_filefunc_def io = zipio_create_io_from_file(&src_f);

                unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
                if (!pkg) {

                    dialog_error->set_text("Error opening package file, not in zip format.");
                    return;
                }

                int ret = unzGoToFirstFile(pkg);

                Vector<String> failed_files;

                int idx=0;
                while(ret==UNZ_OK) {

                    //get filename
                    unz_file_info info;
                    char fname[16384];
                    ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);

                    String path=fname;

                    int depth=1; //stuff from github comes with tag
                    bool skip=false;
                    while(depth>0) {
                        int pp = path.find("/");
                        if (pp==-1) {
                            skip=true;
                            break;
                        }
                        path=path.substr(pp+1,path.length());
                        depth--;
                    }


                    if (skip || path==String()) {
                        //
                    } else if (path.ends_with("/")) { // a dir

                        path=path.substr(0,path.length()-1);

                        DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
                        da->make_dir(dir.plus_file(path));
                        memdelete(da);
//.........这里部分代码省略.........
开发者ID:SPTelur,项目名称:godot,代码行数:101,代码来源:project_manager.cpp

示例3: ok_pressed

void EditorAssetInstaller::ok_pressed() {

    FileAccess *src_f=NULL;
    zlib_filefunc_def io = zipio_create_io_from_file(&src_f);

    unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io);
    if (!pkg) {

        error->set_text("Error opening package file, not in zip format.");
        return;
    }

    int ret = unzGoToFirstFile(pkg);

    Vector<String> failed_files;

    ProgressDialog::get_singleton()->add_task("uncompress","Uncompressing Assets",status_map.size());

    int idx=0;
    while(ret==UNZ_OK) {

        //get filename
        unz_file_info info;
        char fname[16384];
        ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);

        String name=fname;

        if (status_map.has(name) && status_map[name]->is_checked(0)) {

            String path = status_map[name]->get_metadata(0);
            if (path==String()) { // a dir

                String dirpath;
                TreeItem *t = status_map[name];
                while(t) {
                    dirpath=t->get_text(0)+dirpath;
                    t=t->get_parent();
                }

                if (dirpath.ends_with("/")) {
                    dirpath=dirpath.substr(0,dirpath.length()-1);
                }

                DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
                da->make_dir(dirpath);
                memdelete(da);

            } else {

                Vector<uint8_t> data;
                data.resize(info.uncompressed_size);

                //read
                unzOpenCurrentFile(pkg);
                unzReadCurrentFile(pkg,data.ptr(),data.size());
                unzCloseCurrentFile(pkg);

                FileAccess *f=FileAccess::open(path,FileAccess::WRITE);
                if (f) {
                    f->store_buffer(data.ptr(),data.size());
                    memdelete(f);
                } else {
                    failed_files.push_back(path);
                }

                ProgressDialog::get_singleton()->task_step("uncompress",path,idx);
            }

        }

        idx++;
        ret = unzGoToNextFile(pkg);
    }

    ProgressDialog::get_singleton()->end_task("uncompress");
    unzClose(pkg);

    if (failed_files.size()) {
        String msg="The following files failed extraction from package:\n\n";
        for(int i=0;i<failed_files.size();i++) {

            if (i>15) {
                msg+="\nAnd "+itos(failed_files.size()-i)+" more files.";
                break;
            }
            msg+=failed_files[i];
        }
        if (EditorNode::get_singleton() != NULL)
            EditorNode::get_singleton()->show_warning(msg);
    } else {
        if (EditorNode::get_singleton() != NULL)
            EditorNode::get_singleton()->show_warning("Package Installed Successfully!","Success!");
    }




}
开发者ID:03050903,项目名称:godot,代码行数:99,代码来源:editor_asset_installer.cpp


注:本文中的DirAccess::make_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。