abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioaUtil.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [ioaUtil.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Command processing package.]
8 
9  Synopsis [Procedures to read binary AIGER format developed by
10  Armin Biere, Johannes Kepler University (http://fmv.jku.at/)]
11 
12  Author [Alan Mishchenko]
13 
14  Affiliation [UC Berkeley]
15 
16  Date [Ver. 1.0. Started - December 16, 2006.]
17 
18  Revision [$Id: ioaUtil.c,v 1.00 2006/12/16 00:00:00 alanmi Exp $]
19 
20 ***********************************************************************/
21 
22 #include "ioa.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 /// FUNCTION DEFINITIONS ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 /**Function*************************************************************
36 
37  Synopsis [Returns the file size.]
38 
39  Description [The file should be closed.]
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
46 int 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 
62 /**Function*************************************************************
63 
64  Synopsis []
65 
66  Description []
67 
68  SideEffects []
69 
70  SeeAlso []
71 
72 ***********************************************************************/
73 char * 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 
82 /**Function*************************************************************
83 
84  Synopsis [Returns the composite name of the file.]
85 
86  Description []
87 
88  SideEffects []
89 
90  SeeAlso []
91 
92 ***********************************************************************/
93 char * 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 
116 /**Function*************************************************************
117 
118  Synopsis [Returns the time stamp.]
119 
120  Description [The file should be closed.]
121 
122  SideEffects []
123 
124  SeeAlso []
125 
126 ***********************************************************************/
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 
140 ////////////////////////////////////////////////////////////////////////
141 /// END OF FILE ///
142 ////////////////////////////////////////////////////////////////////////
143 
144 
146 
char * Ioa_FileNameGenericAppend(char *pBase, char *pSuffix)
Definition: ioaUtil.c:93
#define SEEK_END
Definition: zconf.h:392
char * Ioa_TimeStamp()
Definition: ioaUtil.c:127
ABC_NAMESPACE_IMPL_START int Ioa_FileSize(char *pFileName)
DECLARATIONS ///.
Definition: ioaUtil.c:46
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
char * strcpy()
char * Ioa_FileNameGeneric(char *FileName)
Definition: ioaUtil.c:73
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
char * strcat()
int strlen()
char * strrchr()
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47