mirror of https://github.com/YosysHQ/abc.git
Added new procedures to read files.
This commit is contained in:
parent
795b5a6ce7
commit
49c13f4f03
|
|
@ -104,8 +104,10 @@ extern char * Extra_FileNameExtension( char * FileName );
|
|||
extern char * Extra_FileNameAppend( char * pBase, char * pSuffix );
|
||||
extern char * Extra_FileNameGeneric( char * FileName );
|
||||
extern char * Extra_FileNameGenericAppend( char * pBase, char * pSuffix );
|
||||
extern int Extra_FileCheck( char * pFileName );
|
||||
extern int Extra_FileSize( char * pFileName );
|
||||
extern char * Extra_FileRead( FILE * pFile );
|
||||
extern char * Extra_FileReadContents( char * pFileName );
|
||||
extern int Extra_FileIsType( char * pFileName, char * pS1, char * pS2, char * pS3 );
|
||||
extern char * Extra_TimeStamp();
|
||||
extern char * Extra_StringAppend( char * pStrGiven, char * pStrAdd );
|
||||
|
|
|
|||
|
|
@ -192,6 +192,33 @@ char * Extra_FileNameGenericAppend( char * pBase, char * pSuffix )
|
|||
return Buffer;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Returns the file size.]
|
||||
|
||||
Description [The file should be closed.]
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Extra_FileCheck( char * pFileName )
|
||||
{
|
||||
FILE * pFile;
|
||||
pFile = fopen( pFileName, "rb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Extra_FileCheck(): File \"%s\" does not exist.\n", pFileName );
|
||||
return 0;
|
||||
}
|
||||
fseek( pFile, 0, SEEK_END );
|
||||
if ( ftell( pFile ) == 0 )
|
||||
printf( "Extra_FileCheck(): File \"%s\" is empty.\n", pFileName );
|
||||
fclose( pFile );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Returns the file size.]
|
||||
|
|
@ -207,7 +234,7 @@ int Extra_FileSize( char * pFileName )
|
|||
{
|
||||
FILE * pFile;
|
||||
int nFileSize;
|
||||
pFile = fopen( pFileName, "r" );
|
||||
pFile = fopen( pFileName, "rb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Extra_FileSize(): The file is unavailable (absent or open).\n" );
|
||||
|
|
@ -250,6 +277,28 @@ char * Extra_FileRead( FILE * pFile )
|
|||
return pBuffer;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Read the file into the internal buffer.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
char * Extra_FileReadContents( char * pFileName )
|
||||
{
|
||||
FILE * pFile;
|
||||
char * pBuffer;
|
||||
pFile = fopen( pFileName, "rb" );
|
||||
pBuffer = pFile ? Extra_FileRead( pFile ) : NULL;
|
||||
if ( pFile )
|
||||
fclose( pFile );
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Returns one if the file has a given extension.]
|
||||
|
|
|
|||
Loading…
Reference in New Issue