Esempio n. 1
0
ERetVal CFile::Open( const char* _pszFileName )
{
	ERetVal eRetVal = RET_OK;
		
	ASSERT( _pszFileName );

	if (_pszFileName==NULL )
	{
		eRetVal = RET_ERR;
		LOG(("ERR: NULL filename\n"));
	}
		
		
	if (eRetVal==RET_OK)
	{
		SAFE_DELETE_ARRAY( m_pszFileName );
						
		if (m_bLanguageVersions)
			m_pszFileName = BuildLanguageFileName( _pszFileName );
		else
			m_pszFileName = ALLOC_COPY_STRING( _pszFileName );
				 
		eRetVal = Open_LowLvl( m_pszFileName );
		if (eRetVal!=RET_OK)
		{
			if (m_bLog)
				LOG(("ERR: cant open the file. Maybe it does not exist.: '%s'", m_pszFileName));
		}
	}
		
	UpdateError( eRetVal );
		
	return eRetVal;
}
Esempio n. 2
0
ERetVal CFile::OpenWrite( const char* _pszFileName )
{
	ERetVal eRetVal = RET_OK;
		
	ASSERT( _pszFileName );

	if (_pszFileName==NULL )
	{
		eRetVal = RET_ERR;
		LOG(("ERR: Nombre de fichero NULL en OpenWrite"));
	}
		
	if (eRetVal==RET_OK)
	{
		SAFE_DELETE_ARRAY( m_pszFileName );
		m_pszFileName     = ALLOC_COPY_STRING( _pszFileName );
				 
		FILE* fp = fopen( m_pszFileName, "wb" );
				
		if (!fp)  // if there is an error, assumes it is because the directory is not created, and so it tries to create all the directory chain
		{
			char szDir[ MAX_FILENAME_SIZE ];
			COPY_STRING( szDir, m_pszFileName );        
			char* psz = szDir;
			char* pszSlash = NULL;
			do
			{
				char* pszSlash = strchr( psz, '/' );
				if (pszSlash)
				{
					*pszSlash = 0;
					_mkdir( szDir );
					*pszSlash = '/';
					psz = pszSlash + 1;
				}
			} while (pszSlash!=0);
						
			fp = fopen( m_pszFileName, "wb" );  // then tries to create the file again
		}
				
		if (!fp)  // if still cant, then error
		{
			eRetVal = RET_ERR;
			if (m_bLog)
				LOG(("ERR: when trying to open the file (does not exist or cant be read): '%s'", m_pszFileName));
		}
						
		m_pFile = fp;
	}
		
	UpdateError( eRetVal );
	return eRetVal;
}
Esempio n. 3
0
void parse_args(int argc, char * argv[])
{
	ALLOC_COPY_STRING(((argc > 2) ?  argv[2] : "127.0.0.1"), _host);
	ALLOC_COPY_STRING(argv[1], _mon_iface);
}