Changes to make p21read EXAMPLE_SCHEMA read and write
This commit is contained in:
@@ -278,12 +278,12 @@ STEPfile::OpenOutputFile( const char * filename ) {
|
||||
}
|
||||
}
|
||||
|
||||
if( _currentDir->FileExists( TruncFileName( FileName() ) ) ) {
|
||||
if( _currentDir->FileExists( TruncFileName( filename ) ) ) {
|
||||
MakeBackupFile();
|
||||
}
|
||||
// ostream* out = new ostream(FileName(), io_writeonly, a_create);
|
||||
// - port 29-Mar-1994 kcm
|
||||
ofstream * out = new ofstream( FileName() );
|
||||
ofstream * out = new ofstream( filename );
|
||||
// default for ostream is writeonly and protections are set to 644
|
||||
if( !out ) {
|
||||
_error.AppendToUserMsg( "unable to open file for output\n" );
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// debug_level >= 2 => tells when a command is chosen
|
||||
// debug_level >= 3 => prints values within functions:
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static int debug_level = 2;
|
||||
static int debug_level = 3;
|
||||
// if debug_level is greater than this number then
|
||||
// function names get printed out when executed
|
||||
//static int PrintFunctionTrace = 2;
|
||||
|
||||
@@ -885,7 +885,8 @@ STEPattribute::is_null() const {
|
||||
return ( *( ptr.c ) == S_ENTITY_NULL );
|
||||
|
||||
case STRING_TYPE:
|
||||
ptr.S->clear();
|
||||
// rok
|
||||
//ptr.S->clear();
|
||||
return ptr.S->empty();
|
||||
|
||||
case BINARY_TYPE:
|
||||
|
||||
@@ -115,8 +115,8 @@ const char * DirObj::RealPath( const char * path ) {
|
||||
|
||||
boolean DirObj::LoadDirectory( const char * name ) {
|
||||
char buf[MAXPATHLEN + 2];
|
||||
|
||||
strcpy( buf, ValidDirectories( RealPath( name ) ) );
|
||||
strcpy( buf, RealPath( name ) );
|
||||
// strcpy( buf, ValidDirectories( RealPath( name ) ) );
|
||||
return Reset( buf );
|
||||
}
|
||||
|
||||
@@ -145,7 +145,8 @@ int DirObj::Index( const char * name ) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
boolean DirObj::Reset( const char * path ) {
|
||||
boolean successful = IsADirectory( path );
|
||||
// boolean successful = IsADirectory( path );
|
||||
boolean successful = true;
|
||||
if( successful ) {
|
||||
DIR * dir = opendir( path );
|
||||
ClearFileList();
|
||||
|
||||
@@ -310,6 +310,34 @@ HASHdestroy( Hash_Table table ) {
|
||||
}
|
||||
}
|
||||
|
||||
// rok
|
||||
void *
|
||||
HASHfind( Hash_Table t, char * s ) {
|
||||
// Element * ep;
|
||||
struct Element_ *ep = malloc(sizeof *ep);
|
||||
struct Element_ *e = malloc(sizeof *e);
|
||||
e -> key = s;
|
||||
e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */
|
||||
ep = HASHsearch( t, e, HASH_FIND );
|
||||
return( ep ? ep->data : 0 );
|
||||
}
|
||||
|
||||
|
||||
// rok
|
||||
void
|
||||
HASHinsert( Hash_Table t, char * s, void * data ) {
|
||||
Element *e2;
|
||||
// memset(e, 0, sizeof(s) + sizeof(data));
|
||||
struct Element_ *e = malloc(sizeof *e);
|
||||
e -> key = s;
|
||||
e -> data = data;
|
||||
e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */
|
||||
e2 = HASHsearch( t, e, HASH_INSERT );
|
||||
if( e2 ) {
|
||||
printf( "Redeclaration of %s\n", s );
|
||||
}
|
||||
}
|
||||
|
||||
Element
|
||||
HASHsearch( Hash_Table table, Element item, Action action ) {
|
||||
Address h;
|
||||
|
||||
@@ -46,6 +46,7 @@ int main( int argc, char * argv[] ) {
|
||||
flnm = ( char * )"testfile.step";
|
||||
}
|
||||
sfile.ReadExchangeFile( flnm );
|
||||
sfile.Error().PrintContents(cout);
|
||||
|
||||
cout << "EXAMPLE : write file ..." << endl;
|
||||
if( argc == 3 ) {
|
||||
@@ -54,5 +55,6 @@ int main( int argc, char * argv[] ) {
|
||||
flnm = ( char * )"file.out";
|
||||
}
|
||||
sfile.WriteExchangeFile( flnm );
|
||||
sfile.Error().PrintContents(cout);
|
||||
cout << flnm << " written" << endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user