|
@@ -245,7 +245,6 @@ bool M3Datei::saveModel( Model3DData *zMdr, const char *name )
|
|
|
d.remove();
|
|
|
neu.close();
|
|
|
neu.umbenennen( pfad );
|
|
|
- leseDaten();
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -264,8 +263,79 @@ bool M3Datei::removeModel( Text *name )
|
|
|
|
|
|
bool M3Datei::removeModel( const char *name )
|
|
|
{
|
|
|
-
|
|
|
- return 0;
|
|
|
+ if( !modelName || !pfad.getLength() )
|
|
|
+ return 0;
|
|
|
+ if( !hatModel( name ) )
|
|
|
+ return 0;
|
|
|
+ Datei d;
|
|
|
+ d.setDatei( pfad );
|
|
|
+ if( !d.open( Datei::Style::lesen ) )
|
|
|
+ return 0;
|
|
|
+ __int64 startPosition = modelPos->get( 0 );
|
|
|
+ Datei neu;
|
|
|
+ neu.setDatei( pfad );
|
|
|
+ neu.zPfad()->append( "0" );
|
|
|
+ while( neu.existiert() )
|
|
|
+ neu.zPfad()->append( "0" );
|
|
|
+ if( !neu.open( Datei::Style::schreiben ) )
|
|
|
+ {
|
|
|
+ d.close();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ char anz = (char)(modelName->getEintragAnzahl() - 1);
|
|
|
+ neu.schreibe( &anz, 1 );
|
|
|
+ __int64 offset = textLength( name ) + 9;
|
|
|
+ __int64 removedLength = 0;
|
|
|
+ __int64 removedPosition = 0;
|
|
|
+ int removedIndex = 0;
|
|
|
+ for( int i = 0; i < anz + 1; i++ )
|
|
|
+ {
|
|
|
+ if( !modelName->z( i )->istGleich( name ) )
|
|
|
+ {
|
|
|
+ char len = (char)modelName->z( i )->getLength();
|
|
|
+ neu.schreibe( &len, 1 );
|
|
|
+ neu.schreibe( modelName->z( i )->getText(), len );
|
|
|
+ modelPos->set( modelPos->get( i ) - offset, i );
|
|
|
+ __int64 pos = modelPos->get( i );
|
|
|
+ neu.schreibe( (char *)& pos, 8 );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ removedPosition = modelPos->get( i );
|
|
|
+ removedIndex = i;
|
|
|
+ if( modelName->getEintragAnzahl() > i + 1 )
|
|
|
+ {
|
|
|
+ removedLength = modelPos->get( i + 1 ) - modelPos->get( i );
|
|
|
+ offset += removedLength;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ d.setLPosition( startPosition, 0 );
|
|
|
+ __int64 dl = removedPosition - startPosition;
|
|
|
+ char bytes[ 2048 ];
|
|
|
+ while( dl )
|
|
|
+ {
|
|
|
+ int l = dl > 2048 ? 2048 : (int)dl;
|
|
|
+ d.lese( bytes, l );
|
|
|
+ neu.schreibe( bytes, l );
|
|
|
+ dl -= l;
|
|
|
+ }
|
|
|
+ d.setLPosition( removedPosition + removedLength, 0 );
|
|
|
+ dl = d.getSize() - removedPosition - removedLength;
|
|
|
+ while( dl )
|
|
|
+ {
|
|
|
+ int l = dl > 2048 ? 2048 : (int)dl;
|
|
|
+ d.lese( bytes, l );
|
|
|
+ neu.schreibe( bytes, l );
|
|
|
+ dl -= l;
|
|
|
+ }
|
|
|
+ d.close();
|
|
|
+ d.remove();
|
|
|
+ neu.close();
|
|
|
+ neu.umbenennen( pfad );
|
|
|
+ modelName->remove( removedIndex );
|
|
|
+ modelPos->remove( removedIndex );
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -283,6 +353,8 @@ Model3DData *M3Datei::ladeModel( Text *name ) const
|
|
|
|
|
|
Model3DData *M3Datei::ladeModel( const char *name ) const
|
|
|
{
|
|
|
+ if( !modelName || !pfad.getLength() )
|
|
|
+ return 0;
|
|
|
__int64 pos = -1;
|
|
|
auto p = modelPos->getIterator();
|
|
|
for( auto n = modelName->getIterator(); n && p; n++, p++ )
|
|
@@ -355,6 +427,8 @@ Model3DData *M3Datei::ladeModel( const char *name ) const
|
|
|
|
|
|
bool M3Datei::hatModel( const char *name ) const
|
|
|
{
|
|
|
+ if( !modelName || !pfad.getLength() )
|
|
|
+ return 0;
|
|
|
for( auto n = modelName->getIterator(); n; n++ )
|
|
|
{
|
|
|
if( n->istGleich( name ) )
|
|
@@ -366,6 +440,8 @@ bool M3Datei::hatModel( const char *name ) const
|
|
|
|
|
|
int M3Datei::getModelAnzahl() const
|
|
|
{
|
|
|
+ if( !modelName || !pfad.getLength() )
|
|
|
+ return 0;
|
|
|
return modelName->getEintragAnzahl();
|
|
|
}
|
|
|
|
|
@@ -374,6 +450,8 @@ int M3Datei::getModelAnzahl() const
|
|
|
|
|
|
Text *M3Datei::zModelName( int i ) const
|
|
|
{
|
|
|
+ if( !modelName || !pfad.getLength() )
|
|
|
+ return 0;
|
|
|
return modelName->z( i );
|
|
|
}
|
|
|
|