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 
24 ABC_NAMESPACE_IMPL_START
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 ***********************************************************************/
Ioa_FileSize(char * pFileName)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 ***********************************************************************/
Ioa_FileNameGeneric(char * FileName)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 ***********************************************************************/
Ioa_FileNameGenericAppend(char * pBase,char * pSuffix)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 ***********************************************************************/
Ioa_TimeStamp()127 char * Ioa_TimeStamp()
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 
145 ABC_NAMESPACE_IMPL_END
146 
147