// Open a file to read FUFile* FUFileManager::OpenFile(const fstring& filename, bool write, SchemeOnCompleteCallback* onComplete, size_t userData) { // Make sure we have a absolute URI fstring absoluteFilename = GetCurrentUri().MakeAbsolute(filename); FUUri uri(absoluteFilename); // Get the callback SchemeCallbacks* callbacks = NULL; SchemeCallbackMap::iterator it = schemeCallbackMap.find(uri.GetScheme()); if (it != schemeCallbackMap.end()) callbacks = it->second; if (callbacks != NULL) { if (onComplete == NULL) { // No callback provided so the open is blocking if (callbacks->load != NULL) { // We have a callback for this scheme absoluteFilename = (*callbacks->load)(uri); } } else { if (callbacks->request != NULL) { (*callbacks->request)(uri, onComplete, userData); // No file to return return NULL; } } if (!callbacks->openers.empty()) { size_t i = 0; do { for (i = 0; i < callbacks->openers.size(); i++) { fstring newAbsolutePath; if ((*callbacks->openers[i])(absoluteFilename, newAbsolutePath)) { // keep this path absoluteFilename = newAbsolutePath; // override the URI pathStack.back() = FUUri(absoluteFilename); break; } } } while(i != callbacks->openers.size()); // Allow pre-processes to process in any order } } return new FUFile(absoluteFilename.c_str(), write ? FUFile::WRITE : FUFile::READ); }
FUUri FCDEntityReference::GetUri() const { fstring path; if (placeHolder != NULL) { FUUri uri(placeHolder->GetFileUrl()); path = uri.GetAbsoluteUri(); } path.append(FC("#")); if (entity != NULL) path.append(TO_FSTRING(entity->GetDaeId())); else path.append(TO_FSTRING(entityId)); return FUUri(path); }
bool FArchiveXML::LoadControllerInstance(FCDObject* object, xmlNode* instanceNode) { if (!FArchiveXML::LoadGeometryInstance(object, instanceNode)) return false; bool status = true; FCDControllerInstance* controllerInstance = (FCDControllerInstance*)object; xmlNodeList skeletonList; FUDaeParser::FindChildrenByType(instanceNode, DAE_SKELETON_ELEMENT, skeletonList); size_t numRoots = skeletonList.size(); controllerInstance->GetSkeletonRoots().resize(numRoots); for (size_t i = 0; i < numRoots; ++i) { controllerInstance->GetSkeletonRoots()[i] = FUUri(TO_FSTRING(FUDaeParser::ReadNodeContentDirect(skeletonList[i]))); } return status; }
// Set a new root path void FUFileManager::PushRootPath(const fstring& path) { fstring absolutePath = GetCurrentUri().MakeAbsolute(path); if (absolutePath.length() > 0 && absolutePath.back() != '\\' && absolutePath.back() != '/') absolutePath.append((fchar) '/'); pathStack.push_back(FUUri(absolutePath)); }
// Parse the Url attribute off a node FUUri ReadNodeUrl(xmlNode* node, const char* attribute) { fm::string uriString = ReadNodeProperty(node, attribute); return FUUri(TO_FSTRING(uriString)); }