void EditorFileSystem::_scan_filesystem() { ERR_FAIL_COND(!scanning || new_filesystem); //read .fscache String cpath; sources_changed.clear(); file_cache.clear(); String project = ProjectSettings::get_singleton()->get_resource_path(); String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2"); FileAccess *f = FileAccess::open(fscache, FileAccess::READ); if (f) { //read the disk cache while (!f->eof_reached()) { String l = f->get_line().strip_edges(); if (l == String()) continue; if (l.begins_with("::")) { Vector<String> split = l.split("::"); ERR_CONTINUE(split.size() != 3); String name = split[1]; cpath = name; } else { Vector<String> split = l.split("::"); ERR_CONTINUE(split.size() != 5); String name = split[0]; String file; file = name; name = cpath.plus_file(name); FileCache fc; fc.type = split[1]; fc.modification_time = split[2].to_int64(); fc.import_modification_time = split[3].to_int64(); String deps = split[4].strip_edges(); if (deps.length()) { Vector<String> dp = deps.split("<>"); for (int i = 0; i < dp.size(); i++) { String path = dp[i]; fc.deps.push_back(path); } } file_cache[name] = fc; } } f->close(); memdelete(f); } String update_cache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update2"); print_line("try to see fs update2"); if (FileAccess::exists(update_cache)) { print_line("it exists"); { FileAccessRef f = FileAccess::open(update_cache, FileAccess::READ); String l = f->get_line().strip_edges(); while (l != String()) { print_line("erased cache for: " + l + " " + itos(file_cache.has(l))); file_cache.erase(l); //erase cache for this, so it gets updated l = f->get_line().strip_edges(); } } DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); d->remove(update_cache); //bye bye update cache } EditorProgressBG scan_progress("efs", "ScanFS", 1000); ScanProgress sp; sp.low = 0; sp.hi = 1; sp.progress = &scan_progress; new_filesystem = memnew(EditorFileSystemDirectory); new_filesystem->parent = NULL; DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); d->change_dir("res://"); _scan_new_dir(new_filesystem, d, sp); file_cache.clear(); //clear caches, no longer needed memdelete(d); //save back the findings //String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache"); f = FileAccess::open(fscache, FileAccess::WRITE); _save_filesystem_cache(new_filesystem, f); f->close(); memdelete(f); scanning = false; }
void EditorFileSystem::_scan_filesystem() { ERR_FAIL_COND(!scanning || new_filesystem); //read .fscache String cpath; sources_changed.clear(); file_cache.clear(); String project=Globals::get_singleton()->get_resource_path(); String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache"); FileAccess *f =FileAccess::open(fscache,FileAccess::READ); if (f) { //read the disk cache while(!f->eof_reached()) { String l = f->get_line().strip_edges(); if (l==String()) continue; if (l.begins_with("::")) { Vector<String> split = l.split("::"); ERR_CONTINUE( split.size() != 3); String name = split[1]; cpath=name; } else { Vector<String> split = l.split("::"); ERR_CONTINUE( split.size() != 5); String name = split[0]; String file; file=name; name=cpath.plus_file(name); FileCache fc; fc.type=split[1]; fc.modification_time=split[2].to_int64(); String meta = split[3].strip_edges(); fc.meta.enabled=false; if (meta.find("<>")!=-1){ Vector<String> spl = meta.split("<>"); int sc = spl.size()-1; if (sc%3==0){ fc.meta.enabled=true; fc.meta.import_editor=spl[0]; fc.meta.sources.resize(sc/3); for(int i=0;i<fc.meta.sources.size();i++) { fc.meta.sources[i].path=spl[1+i*3+0]; fc.meta.sources[i].md5=spl[1+i*3+1]; fc.meta.sources[i].modified_time=spl[1+i*3+2].to_int64(); } } } String deps = split[4].strip_edges(); if (deps.length()) { Vector<String> dp = deps.split("<>"); for(int i=0;i<dp.size();i++) { String path=dp[i]; fc.meta.deps.push_back(path); } } file_cache[name]=fc; } } f->close(); memdelete(f); } EditorProgressBG scan_progress("efs","ScanFS",1000); ScanProgress sp; sp.low=0; sp.hi=1; sp.progress=&scan_progress; new_filesystem = memnew( EditorFileSystemDirectory ); new_filesystem->parent=NULL; DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); d->change_dir("res://"); _scan_new_dir(new_filesystem,d,sp); file_cache.clear(); //clear caches, no longer needed memdelete(d); //save back the findings // String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache"); f=FileAccess::open(fscache,FileAccess::WRITE); _save_filesystem_cache(new_filesystem,f); f->close(); memdelete(f); scanning=false; }
void EditorFileSystem::_scan_scenes() { ERR_FAIL_COND(!scanning || scandir); //read .fscache HashMap<String,FileCache> file_cache; HashMap<String,DirCache> dir_cache; DirCache *dc=NULL; String cpath; sources_changed.clear(); String project=Globals::get_singleton()->get_resource_path(); FileAccess *f =FileAccess::open(project+"/.fscache",FileAccess::READ); if (f) { //read the disk cache while(!f->eof_reached()) { String l = f->get_line().strip_edges(); if (l==String()) continue; if (l.begins_with("::")) { Vector<String> split = l.split("::"); ERR_CONTINUE( split.size() != 3); String name = split[1]; dir_cache[name]=DirCache(); dc=&dir_cache[name]; dc->modification_time=split[2].to_int64(); if (name!="res://") { cpath=name+"/"; int sp=name.find_last("/"); if (sp==5) sp=6; String pd = name.substr(0,sp); DirCache *dcp = dir_cache.getptr(pd); ERR_CONTINUE(!dcp); dcp->subdirs.insert(name.get_file()); } else { cpath=name; } } else { Vector<String> split = l.split("::"); ERR_CONTINUE( split.size() != 4); String name = split[0]; String file; if (!name.begins_with("res://")) { file=name; name=cpath+name; } else { file=name.get_file(); } FileCache fc; fc.type=split[1]; fc.modification_time=split[2].to_int64(); String meta = split[3].strip_edges(); fc.meta.enabled=false; if (meta.find("<>")!=-1){ Vector<String> spl = meta.split("<>"); int sc = spl.size()-1; if (sc%3==0){ fc.meta.enabled=true; fc.meta.import_editor=spl[0]; fc.meta.sources.resize(sc/3); for(int i=0;i<fc.meta.sources.size();i++) { fc.meta.sources[i].path=spl[1+i*3+0]; fc.meta.sources[i].md5=spl[1+i*3+1]; fc.meta.sources[i].modified_time=spl[1+i*3+2].to_int64(); } } } file_cache[name]=fc; ERR_CONTINUE(!dc); dc->files.insert(file); } } f->close(); memdelete(f); } total=0; DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); //da->change_dir( Globals::get_singleton()->get_resource_path() ); List<String> extensionsl; ResourceLoader::get_recognized_extensions_for_type("",&extensionsl); Set<String> extensions; for(List<String>::Element *E = extensionsl.front();E;E=E->next()) { extensions.insert(E->get()); } EditorProgressBG scan_progress("efs","ScanFS",100); md_count=0; scandir=_scan_dir(da,extensions,"",0,1,"",file_cache,dir_cache,scan_progress); memdelete(da); if (abort_scan && scandir) { memdelete(scandir); scandir=NULL; } //save back the findings f=FileAccess::open(project+"/.fscache",FileAccess::WRITE); _save_type_cache_fs(scandir,f); f->close(); memdelete(f); scanning=false; }