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


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

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


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

示例1: _test_path

	bool _test_path() {

		error->set_text("");
		get_ok()->set_disabled(true);
		DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
		if (d->change_dir(project_path->get_text())!=OK) {
			error->set_text("Invalid Path for Project, Path Must Exist!");
			memdelete(d);
			return false;
		}

		if (!import_mode) {

			if (d->file_exists("engine.cfg")) {

				error->set_text("Invalid Project Path (engine.cfg must not exist).");
				memdelete(d);
				return false;
			}

		} else {

			if (!d->file_exists("engine.cfg")) {

				error->set_text("Invalid Project Path (engine.cfg must exist).");
				memdelete(d);
				return false;
			}
		}

		memdelete(d);
		get_ok()->set_disabled(false);
		return true;

	}
开发者ID:0871087123,项目名称:godot,代码行数:35,代码来源:project_manager.cpp

示例2: _test_path

	bool _test_path() {

		error->set_text("");
		get_ok()->set_disabled(true);
		DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
		if (project_path->get_text() != "" && d->change_dir(project_path->get_text())!=OK) {
			error->set_text(TTR("Invalid project path, the path must exist!"));
			memdelete(d);
			return false;
		}

		if (mode!=MODE_IMPORT) {

			if (d->file_exists("engine.cfg")) {

				error->set_text(TTR("Invalid project path, engine.cfg must not exist."));
				memdelete(d);
				return false;
			}

		} else {

			if (project_path->get_text() != "" && !d->file_exists("engine.cfg")) {

				error->set_text(TTR("Invalid project path, engine.cfg must exist."));
				memdelete(d);
				return false;
			}
		}

		memdelete(d);
		get_ok()->set_disabled(false);
		return true;

	}
开发者ID:SPTelur,项目名称:godot,代码行数:35,代码来源:project_manager.cpp

示例3: _test_path

	String _test_path() {

		error->set_text("");
		get_ok()->set_disabled(true);
		DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
		String valid_path;
		if (d->change_dir(project_path->get_text())==OK){
			valid_path=project_path->get_text();
		} else if (d->change_dir(project_path->get_text().strip_edges())==OK) {
			valid_path=project_path->get_text().strip_edges();
		}

		if (valid_path == "") {
			error->set_text(TTR("Invalid project path, the path must exist!"));
			memdelete(d);
			return "";
		}

		if (mode!=MODE_IMPORT) {

			if (d->file_exists("godot.cfg")) {

				error->set_text(TTR("Invalid project path, godot.cfg must not exist."));
				memdelete(d);
				return "";
			}

		} else {

			if (valid_path != "" && !d->file_exists("godot.cfg")) {

				error->set_text(TTR("Invalid project path, godot.cfg must exist."));
				memdelete(d);
				return "";
			}
		}

		memdelete(d);
		get_ok()->set_disabled(false);
		return valid_path;

	}
开发者ID:pkowal1982,项目名称:godot,代码行数:42,代码来源:project_manager.cpp

示例4: _path_changed

void ScriptCreateDialog::_path_changed(const String &p_path) {

	is_path_valid = false;
	is_new_script_created = true;
	String p = p_path;

	if (p == "") {
		_msg_path_valid(false, TTR("Path is empty"));
		_update_dialog();
		return;
	}

	p = ProjectSettings::get_singleton()->localize_path(p);
	if (!p.begins_with("res://")) {
		_msg_path_valid(false, TTR("Path is not local"));
		_update_dialog();
		return;
	}

	if (p.find("/") || p.find("\\")) {
		DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
		if (d->change_dir(p.get_base_dir()) != OK) {
			_msg_path_valid(false, TTR("Invalid base path"));
			memdelete(d);
			_update_dialog();
			return;
		}
		memdelete(d);
	}

	/* Does file already exist */

	DirAccess *f = DirAccess::create(DirAccess::ACCESS_RESOURCES);
	if (f->dir_exists(p)) {
		is_new_script_created = false;
		is_path_valid = false;
		_msg_path_valid(false, TTR("Directory of the same name exists"));
	} else if (f->file_exists(p)) {
		is_new_script_created = false;
		is_path_valid = true;
		_msg_path_valid(true, TTR("File exists, will be reused"));
	} else {
		path_error_label->set_text("");
	}
	memdelete(f);
	_update_dialog();

	/* Check file extension */

	String extension = p.get_extension();
	List<String> extensions;

	// get all possible extensions for script
	for (int l = 0; l < language_menu->get_item_count(); l++) {
		ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
	}

	bool found = false;
	bool match = false;
	int index = 0;
	for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
		if (E->get().nocasecmp_to(extension) == 0) {
			//FIXME (?) - changing language this way doesn't update controls, needs rework
			//language_menu->select(index); // change Language option by extension
			found = true;
			if (E->get() == ScriptServer::get_language(language_menu->get_selected())->get_extension()) {
				match = true;
			}
			break;
		}
		index++;
	}

	if (!found) {
		_msg_path_valid(false, TTR("Invalid extension"));
		_update_dialog();
		return;
	}

	if (!match) {
		_msg_path_valid(false, TTR("Wrong extension chosen"));
		_update_dialog();
		return;
	}

	/* All checks passed */

	is_path_valid = true;
	_update_dialog();
}
开发者ID:arcanis,项目名称:godot,代码行数:90,代码来源:script_create_dialog.cpp


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