/** Se elimina un indice primiraio*/ public void eliminaIndicePrimario(CNodoEntidad e, CIndice ind) { CIndice bloAux, bloAnt; long ptrAux, ptrAnt; bloAux = bloAnt = null; ptrAux = ptrAnt = -1; ptrAux = e.getApCabDatos(); while (ptrAux != -1) { bloAux = getArchivo().LeerIndicePrimario(ptrAux); if (ind.comparateTo(bloAux) != 0 ) { ptrAnt = ptrAux; bloAnt = bloAux; ptrAux = bloAux.getSigInd(); } else break; } if (ptrAux == e.getApCabDatos()) { e.setApCabDatos(bloAux.getSigInd()); getArchivo().escribeEntidad(e, e.getDir()); } else { bloAnt.setSigInd(bloAux.getSigInd()); getArchivo().EscribeIndicePrimario(bloAnt); } }
/**\brief Inserta un bloque de datos a la organización*/ public int AltaOSI(CNodoEntidad e, CBloque nuevo, long posB) { CIndice indPri, indAux = null; int res; long ptrAux, posInd; indPri = generaIndPri(nuevo); getArchivo().AbrirArchivo(); ptrAux = e.getApCabDatos(); while (ptrAux != -1) { indPrim = getArchivo().LeerIndicePrimario(ptrAux); if (indPrim.comparateTo(indPri) != 0) ptrAux = indPrim.getSigInd(); else break; } if (ptrAux == -1) { posInd = getArchivo().getFS().Length; insIndicePri(e, ref indPri,posInd); posB = getArchivo().getFS().Length; indPrim = indPri; res = insBloque(indPri, nuevo, posB); } else res = insBloque(indPrim, nuevo, posB); getArchivo().CerrarArchivo(); return (res); }