ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioaUtil.c
Go to the documentation of this file.
1
21
22#include "ioa.h"
23
25
26
30
34
46int Ioa_FileSize( char * pFileName )
47{
48 FILE * pFile;
49 int nFileSize;
50 pFile = fopen( pFileName, "r" );
51 if ( pFile == NULL )
52 {
53 printf( "Ioa_FileSize(): The file is unavailable (absent or open).\n" );
54 return 0;
55 }
56 fseek( pFile, 0, SEEK_END );
57 nFileSize = ftell( pFile );
58 fclose( pFile );
59 return nFileSize;
60}
61
73char * Ioa_FileNameGeneric( char * FileName )
74{
75 char * pDot, * pRes;
76 pRes = Abc_UtilStrsav( FileName );
77 if ( (pDot = strrchr( pRes, '.' )) )
78 *pDot = 0;
79 return pRes;
80}
81
93char * Ioa_FileNameGenericAppend( char * pBase, char * pSuffix )
94{
95 static char Buffer[1000];
96 char * pDot;
97 if ( pBase == NULL )
98 {
99 strcpy( Buffer, pSuffix );
100 return Buffer;
101 }
102 strcpy( Buffer, pBase );
103 if ( (pDot = strrchr( Buffer, '.' )) )
104 *pDot = 0;
105 strcat( Buffer, pSuffix );
106 // find the last occurrance of slash
107 for ( pDot = Buffer + strlen(Buffer) - 1; pDot >= Buffer; pDot-- )
108 if (!((*pDot >= '0' && *pDot <= '9') ||
109 (*pDot >= 'a' && *pDot <= 'z') ||
110 (*pDot >= 'A' && *pDot <= 'Z') ||
111 *pDot == '_' || *pDot == '.') )
112 break;
113 return pDot + 1;
114}
115
128{
129 static char Buffer[100];
130 char * TimeStamp;
131 time_t ltime;
132 // get the current time
133 time( &ltime );
134 TimeStamp = asctime( localtime( &ltime ) );
135 TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
136 strcpy( Buffer, TimeStamp );
137 return Buffer;
138}
139
143
144
146
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
char * Ioa_FileNameGeneric(char *FileName)
Definition ioaUtil.c:73
ABC_NAMESPACE_IMPL_START int Ioa_FileSize(char *pFileName)
DECLARATIONS ///.
Definition ioaUtil.c:46
char * Ioa_TimeStamp()
Definition ioaUtil.c:127
char * Ioa_FileNameGenericAppend(char *pBase, char *pSuffix)
Definition ioaUtil.c:93
char * strrchr()
int strlen()
char * strcpy()
char * strcat()
#define SEEK_END
Definition zconf.h:392