void TextureManager::LoadAllTGA(File *pDirectory, bool bRecursive) { if (pDirectory && pDirectory->IsDirectory()) { File *pFile = 0; for (unsigned int i = 0; i < pDirectory->GetNumChildren(); ++i) { pFile = pDirectory->GetChild(i); if (pFile) { if (pFile->IsDirectory() && bRecursive) { //recursive is set to true, so load this directory as well LoadAllTGA(pFile, bRecursive); } else if (!pFile->IsDirectory()) { //if its not a directory, check to see if the extension is TGA. If so, load the texture! if ((strcmp(pFile->GetExtension().c_str(), "tga") == 0) || (strcmp(pFile->GetExtension().c_str(), "TGA") == 0)) { LoadTexture(pFile->GetName().c_str()); } } } } } }
string User::GetJsonByUserContentList(std::list<UserContent*> list, bool full) { string json; for (std::list<UserContent*>::iterator it=list.begin(); it != list.end(); ++it) { json += "{"; json += "\"identifier\" : " + std::to_string((*it)->identifier) + ","; json += "\"type\" : " + std::to_string((*it)->type) + ","; if(full) { File* file = new File(); file->Load((*it)->identifier); json += "\"name\" : \"" + file->GetName() + "\","; json += "\"extension\" : \"" + file->GetExtension() + "\","; json += "\"sizeMB\" : " + std::to_string(file->GetSize()) + ","; json += "\"owner\" : " + file->GetOwner() + ","; json += "\"tags\" : " + file->GetTagsStr() + ","; if(file->IsDeleted()) json += "\"delete\" : true,"; else json += "\"delete\" : false,"; json += "\"lastModifiedBy\" : \"" + file->GetLastModifiedBy() + "\", "; json += "\"lastModifiedOn\" : \"" + to_string(file->GetLastModifiedOn())+ "\","; json += "\"lastVersion\" : " + std::to_string(file->GetLastVersion()) + ","; json += "\"versions\" :" + file->GetVersionsStr() + ","; delete file; } json += "\"content\" : ["; if((*it)->type == 2) json += GetJsonByUserContentList((*it)->content, full); json += "]"; json += "},"; } return json.substr(0, json.length() - 1); }
string User::GetJsonBySharedFilesList(bool full) { string json; for (std::list<int>::iterator it=sharedFiles.begin(); it != sharedFiles.end(); ++it) { if(full) { File* file = new File(); file->Load(*it); json += "{"; json += "\"identifier\" : " + std::to_string(file->GetIdentifier()) + ","; json += "\"type\" : " + std::to_string(file->GetType()) + ","; json += "\"name\" : \"" + file->GetName() + "\","; json += "\"extension\" : \"" + file->GetExtension() + "\","; json += "\"sizeMB\" : " + std::to_string(file->GetSize()) + ","; json += "\"owner\" : " + file->GetOwner() + ","; json += "\"tags\" : " + file->GetTagsStr() + ","; if(file->IsDeleted()) json += "\"delete\" : true,"; else json += "\"delete\" : false,"; json += "\"lastModifiedOn\" : \"" + to_string(file->GetLastModifiedOn()) + "\","; json += "\"lastModifiedBy\" : \"" + file->GetLastModifiedBy() + "\","; json += "\"lastVersion\" : " + std::to_string(file->GetLastVersion()) + ","; json += "\"versions\" : " + file->GetVersionsStr(); delete file; json += "},"; } else json += std::to_string(*it) + ","; } return json.substr(0, json.length() - 1); }