static bool WREHandleClipDataNames( WREResInfo *info, WResID *type, WResID **name, bool *replace ) { WRECurrentResInfo curr; WREResRenameInfo ren_info; uint_16 t; WResLangType lang; bool exists; bool ok; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; ok = (info != NULL && info->info != NULL && type != NULL && name != NULL && *name != NULL && replace != NULL); if( ok ) { t = 0; if( !type->IsName ) { t = type->ID.Num; } ok = (t != 0); } if( ok ) { exists = WRDoesNameExist( info->info->dir, type, *name ); while( exists ) { ok = WREQueryPasteReplace( *name, t, replace ); if( !ok ) { break; } if( *replace ) { curr.info = info; curr.type = WREFindTypeNodeFromWResID( info->info->dir, type ); curr.res = WREFindResNodeFromWResID( curr.type, *name ); curr.lang = WREFindLangNodeFromLangType( curr.res, &lang ); ok = WREDeleteResource( &curr, TRUE ); if( !ok ) { break; } } else { ren_info.old_name = *name; ren_info.new_name = NULL; ok = (WREGetNewName( &ren_info ) && ren_info.new_name != NULL); if( ok ) { WRMemFree( *name ); *name = ren_info.new_name; } } exists = WRDoesNameExist( info->info->dir, type, *name ); if( exists && *replace ) { ok = false; break; } } } return( ok ); }
bool WRENewResource( WRECurrentResInfo *curr, WResID *tname, WResID *rname, uint_16 memflags, uint_32 offset, uint_32 length, WResLangType *lang, bool *dup, uint_16 type, bool new_type ) { bool ok; ok = (curr != NULL && curr->info != NULL && tname != NULL && rname != NULL && lang != NULL); if( ok && ( curr->info->info->dir == NULL ) ) { ok = ((curr->info->info->dir = WResInitDir()) != NULL); } if( ok ) { ok = !WResAddResource( tname, rname, memflags, offset, length, curr->info->info->dir, lang, dup ); } if( ok ) { ok = (dup == NULL || (dup != NULL && !*dup)); } if( ok ) { if( new_type ) { curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, type ); } else { WRESetResNamesFromType( curr->info, type, TRUE, rname, 0 ); } } if( ok && new_type ) { curr->type = WREFindTypeNodeFromWResID( curr->info->info->dir, tname ); ok = (curr->type != NULL); } if( ok ) { curr->res = WREFindResNodeFromWResID( curr->type, rname ); ok = (curr->res != NULL); } if( ok ) { curr->lang = WREFindLangNodeFromLangType( curr->res, lang ); ok = (curr->lang != NULL); } return( ok ); }