Subversion Repositories spk

Rev

Rev 116 | Rev 124 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 116 Rev 118
Line 2134... Line 2134...
2134
		}
2134
		}
2135
		fileStream.close();
2135
		fileStream.close();
2136
	}
2136
	}
2137
	*/
2137
	*/
2138
 
2138
 
2139
	FILE *fid = fopen(file.c_str(), "r");
2139
	CFileIO F(file);
2140
	if ( fid )
2140
	if ( F.exists() && F.startRead() ) {
2141
	{
-
 
2142
		bool ret = this->AddTextFromFile(fid, textId);
2141
		bool ret = this->_addTextFromFile(F, textId);
2143
		fclose(fid);
2142
		F.close();
2144
 
2143
 
2145
		if ( remove ) CFileIO::Remove(file);
2144
		if ( remove ) CFileIO::Remove(file);
2146
		_changed();
2145
		_changed();
2147
		return ret;
2146
		return ret;
2148
	}
2147
	}
Line 2270... Line 2269...
2270
	}
2269
	}
2271
 
2270
 
2272
	return false;
2271
	return false;
2273
}
2272
}
2274
 
2273
 
2275
bool CXspFile::AddTextFromFile(FILE *id, int textId)
2274
bool CXspFile::_addTextFromFile(CFileIO &F, int textId)
2276
{
2275
{
2277
	if ( textId == -1 && !m_sData.empty() )
2276
	if ( textId == -1 && !m_sData.empty() )
2278
		textId = m_sData.token(";", 7);
2277
		textId = m_sData.token(";", 7);
2279
 
2278
 
2280
	if ( textId <= 0 )
2279
	if ( textId <= 0 )
2281
		return false;
2280
		return false;
2282
 
2281
 
2283
	Utils::String line;
-
 
2284
	if ( !id )
2282
	if ( !F.isOpened() )
2285
		return false;
2283
		return false;
2286
 
2284
 
2287
	bool added = false;
2285
	bool added = false;
2288
 
2286
 
2289
	Utils::String shipName;
2287
	Utils::String shipName;
Line 2291... Line 2289...
2291
 
2289
 
2292
	int lastAddedGameID = 0;
2290
	int lastAddedGameID = 0;
2293
	int currentGameID = 0;
2291
	int currentGameID = 0;
2294
	int lang = 0;
2292
	int lang = 0;
2295
	bool inpage = false;
2293
	bool inpage = false;
-
 
2294
 
2296
	while ( !feof(id) )
2295
	while(!F.atEnd()) {
2297
	{
-
 
2298
		if ( !shipName.empty() && !shipDesc.empty() )
2296
		if ( !shipName.empty() && !shipDesc.empty() )
2299
		{
2297
		{
2300
			added = true;
2298
			added = true;
2301
			break;
2299
			break;
2302
		}
2300
		}
2303
 
2301
 
2304
		line.readToEndOfLine(id, 0, false);
2302
		Utils::String line = F.readEndOfLine();
2305
		line.removeChar(9);
2303
		line.removeChar(9);
2306
		line.removeChar('\r');
2304
		line.removeChar('\r');
2307
		line.removeFirstSpace();
2305
		line.removeFirstSpace();
2308
 
2306
	
2309
		if ( inpage )
2307
		if ( inpage )
2310
		{
2308
		{
2311
			if ( line.left(6).Compare("</page") ) {
2309
			if ( line.left(6).Compare("</page") ) {
2312
				inpage = false;
2310
				inpage = false;
2313
				continue;
2311
				continue;