本文整理汇总了C++中DirAccess::list_dir_end方法的典型用法代码示例。如果您正苦于以下问题:C++ DirAccess::list_dir_end方法的具体用法?C++ DirAccess::list_dir_end怎么用?C++ DirAccess::list_dir_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirAccess
的用法示例。
在下文中一共展示了DirAccess::list_dir_end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _update_template_list
void ExportTemplateManager::_update_template_list() {
while (current_hb->get_child_count()) {
memdelete(current_hb->get_child(0));
}
while (installed_vb->get_child_count()) {
memdelete(installed_vb->get_child(0));
}
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir());
d->list_dir_begin();
Set<String> templates;
if (err == OK) {
bool isdir;
String c = d->get_next(&isdir);
while (c != String()) {
if (isdir && !c.begins_with(".")) {
templates.insert(c);
}
c = d->get_next(&isdir);
}
}
d->list_dir_end();
memdelete(d);
String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS) + VERSION_MODULE_CONFIG;
Label *current = memnew(Label);
current->set_h_size_flags(SIZE_EXPAND_FILL);
current_hb->add_child(current);
if (templates.has(current_version)) {
current->add_color_override("font_color", get_color("success_color", "Editor"));
Button *redownload = memnew(Button);
redownload->set_text(TTR("Re-Download"));
current_hb->add_child(redownload);
redownload->connect("pressed", this, "_download_template", varray(current_version));
Button *uninstall = memnew(Button);
uninstall->set_text(TTR("Uninstall"));
current_hb->add_child(uninstall);
current->set_text(current_version + " " + TTR("(Installed)"));
uninstall->connect("pressed", this, "_uninstall_template", varray(current_version));
} else {
current->add_color_override("font_color", get_color("error_color", "Editor"));
Button *redownload = memnew(Button);
redownload->set_text(TTR("Download"));
redownload->connect("pressed", this, "_download_template", varray(current_version));
current_hb->add_child(redownload);
current->set_text(current_version + " " + TTR("(Missing)"));
}
for (Set<String>::Element *E = templates.back(); E; E = E->prev()) {
HBoxContainer *hbc = memnew(HBoxContainer);
Label *version = memnew(Label);
version->set_modulate(get_color("disabled_font_color", "Editor"));
String text = E->get();
if (text == current_version) {
text += " " + TTR("(Current)");
}
version->set_text(text);
version->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(version);
Button *uninstall = memnew(Button);
uninstall->set_text(TTR("Uninstall"));
hbc->add_child(uninstall);
uninstall->connect("pressed", this, "_uninstall_template", varray(E->get()));
installed_vb->add_child(hbc);
}
}
示例2: test
MainLoop* test() {
print_line("this is test io");
DirAccess* da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->change_dir(".");
print_line("Opening current dir "+ da->get_current_dir());
String entry;
da->list_dir_begin();
while ( (entry = da->get_next()) != "") {
print_line("entry "+entry+" is dir: " + Variant(da->current_is_dir()));
};
da->list_dir_end();
RES texture = ResourceLoader::load("test_data/rock.png");
ERR_FAIL_COND_V(texture.is_null(), NULL);
ResourceSaver::save("test_data/rock.xml",texture);
print_line("localize paths");
print_line(Globals::get_singleton()->localize_path("algo.xml"));
print_line(Globals::get_singleton()->localize_path("c:\\windows\\algo.xml"));
print_line(Globals::get_singleton()->localize_path(Globals::get_singleton()->get_resource_path()+"/something/something.xml"));
print_line(Globals::get_singleton()->localize_path("somedir/algo.xml"));
{
FileAccess* z = FileAccess::open("test_data/archive.zip", FileAccess::READ);
int len = z->get_len();
Vector<uint8_t> zip;
zip.resize(len);
z->get_buffer(&zip[0], len);
z->close();
memdelete(z);
FileAccessMemory::register_file("a_package", zip);
FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_FILESYSTEM);
FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_USERDATA);
print_line("archive test");
#if 0
Archive arch;
Archive::get_singleton()->add_package("a_package");
FileAccessArchive f;
print_line("opening for read");
f._open("file.txt", FileAccess::READ);
int pos = f.get_pos();
printf("file has %i bytes, initial pos %i\n", (int)f.get_len(), pos);
do {
printf("%c", f.get_8());
} while (!f.eof_reached());
print_line("opening for stored seek");
f.open("seek.bin", FileAccess::READ);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(128);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
print_line("opening for deflated seek");
f.open("seek_deflated.bin", FileAccess::READ);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(128);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(256);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(4);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.close();
DirAccessArchive d;
String dir = "../blah1/blah2/blahask/../blah3/.//blah4/";
printf("changing dir to %s\n", dir.utf8().get_data());
d.change_dir(dir);
printf("current dir is %s\n", d.get_current_dir().utf8().get_data());
FileAccessMemory::cleanup();
//.........这里部分代码省略.........
示例3: _scan_fs_changes
//.........这里部分代码省略.........
int idx = p_dir->find_file_index(f);
if (idx == -1) {
//never seen this file, add actition to add it
EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
fi->file = f;
String path = cd.plus_file(fi->file);
fi->modified_time = FileAccess::get_modified_time(path);
fi->import_modified_time = 0;
fi->type = ResourceLoader::get_resource_type(path);
fi->import_valid = ResourceLoader::is_import_valid(path);
{
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_ADD;
ia.dir = p_dir;
ia.file = f;
ia.new_file = fi;
scan_actions.push_back(ia);
}
if (import_extensions.has(ext)) {
//if it can be imported, and it was added, it needs to be reimported
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_REIMPORT;
ia.dir = p_dir;
ia.file = f;
scan_actions.push_back(ia);
}
} else {
p_dir->files[idx]->verified = true;
}
}
}
da->list_dir_end();
memdelete(da);
}
for (int i = 0; i < p_dir->files.size(); i++) {
if (updated_dir && !p_dir->files[i]->verified) {
//this file was removed, add action to remove it
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_REMOVE;
ia.dir = p_dir;
ia.file = p_dir->files[i]->file;
scan_actions.push_back(ia);
continue;
}
if (import_extensions.has(p_dir->files[i]->file.get_extension().to_lower())) {
//check here if file must be imported or not
String path = cd.plus_file(p_dir->files[i]->file);
uint64_t mt = FileAccess::get_modified_time(path);
bool reimport = false;
if (mt != p_dir->files[i]->modified_time) {
reimport = true; //it was modified, must be reimported.
} else if (!FileAccess::exists(path + ".import")) {
reimport = true; //no .import file, obviously reimport
} else {
uint64_t import_mt = FileAccess::get_modified_time(path + ".import");
if (import_mt != p_dir->files[i]->import_modified_time) {
reimport = true;
} else if (!_check_missing_imported_files(path)) {
reimport = true;
}
}
if (reimport) {
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_REIMPORT;
ia.dir = p_dir;
ia.file = p_dir->files[i]->file;
scan_actions.push_back(ia);
}
}
}
for (int i = 0; i < p_dir->subdirs.size(); i++) {
if (updated_dir && !p_dir->subdirs[i]->verified) {
//this directory was removed, add action to remove it
ItemAction ia;
ia.action = ItemAction::ACTION_DIR_REMOVE;
ia.dir = p_dir->subdirs[i];
scan_actions.push_back(ia);
continue;
}
_scan_fs_changes(p_dir->get_subdir(i), p_progress);
}
}