ANIM_RES *C_Animation::LoadAnim(long ID,char *filename) { ANIM_RES *cur,*NewAnim; UI_HANDLE ifp; long size; if(GetAnim(ID)) return(NULL); ifp=UI_OPEN(filename,"rb"); if(ifp == NULL) return(NULL); size=UI_FILESIZE(ifp); if(!size) { UI_CLOSE(ifp); return(FALSE); } NewAnim=new ANIM_RES; NewAnim->ID=ID; NewAnim->Anim=(ANIMATION *)((void*)new char [size+1]); NewAnim->flags=0; NewAnim->Next=NULL; if(NewAnim->Anim == NULL) { delete NewAnim; UI_CLOSE(ifp); return(NULL); } if(UI_READ(NewAnim->Anim,size,1,ifp) != 1) { delete NewAnim->Anim; delete NewAnim; UI_CLOSE(ifp); return(NULL); } UI_CLOSE(ifp); ConvertAnim(NewAnim->Anim); cur=Root_; if(cur == NULL) { Root_=NewAnim; } else { while(cur->Next) cur=cur->Next; cur->Next=NewAnim; } return(NewAnim); }
void ConvertDirectory(const char *strFullPath, char *strRelativePath, double MaxMSE) { // Set our current directory if (strFullPath) SetCurrentDirectory(strFullPath); // Get our current pathname char strCurrentPath[MAX_PATH]; GetCurrentDirectory(MAX_PATH, strCurrentPath); // Now run through our directory, and find all subdirs WIN32_FIND_DATAA FindData; char Filename[4] = "*.*"; HANDLE hFind = FindFirstFile(Filename, &FindData); if (hFind != INVALID_HANDLE_VALUE) { do { // Check if we've found a subdir if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { // ignore any directory starting with a '.' if (strnicmp(FindData.cFileName,".",1)) { char strNewFullPath[MAX_PATH]; char strNewRelativePath[MAX_PATH]; sprintf(strNewFullPath, "%s\\%s", strCurrentPath, FindData.cFileName); if (strRelativePath) sprintf(strNewRelativePath, "%s\\%s", strRelativePath, FindData.cFileName); else sprintf(strNewRelativePath, "%s", FindData.cFileName); // Recurse into the new directory ConvertDirectory(strNewFullPath, strNewRelativePath, MaxMSE); // Restore our current directory SetCurrentDirectory(strCurrentPath); } } else { // just files - check if it's an allowed graphics file if (IsGraphicsFile(FindData.cFileName)) { // got a graphics file ConvertFile(strRelativePath,FindData.cFileName, MaxMSE); } if (IsGraphicsAnim(FindData.cFileName)) { // got a .gif anim ConvertAnim(strRelativePath,FindData.cFileName, MaxMSE); } } } while (FindNextFile(hFind, &FindData)); FindClose(hFind); } }