Subversion Repositories spk

Rev

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

Rev 57 Rev 58
Line 253... Line 253...
253
	File.close();
253
	File.close();
254
	this->close();
254
	this->close();
255
	File.setAutoDelete(false);
255
	File.setAutoDelete(false);
256
 
256
 
257
	// now copy to original file
257
	// now copy to original file
258
	std::remove(m_sFilename.c_str());
258
	if ( std::remove(m_sFilename.c_str()) == 0 ) {
259
	std::rename("temp.tmp", m_sFilename.c_str());
259
		std::rename("temp.tmp", m_sFilename.c_str());
-
 
260
		return FILEERR_NONE;
-
 
261
	}
260
 
262
 
261
	return FILEERR_NONE;
263
	return FILEERR_NOWRITE;
262
}
264
}
263
 
265
 
264
int CFileIO::_in() const
266
int CFileIO::_in() const
265
{
267
{
266
	if ( m_bBinary ) return std::ios::in | std::ios::binary;
268
	if ( m_bBinary ) return std::ios::in | std::ios::binary;
Line 652... Line 654...
652
}
654
}
653
 
655
 
654
 
656
 
655
bool CFileIO::AppendData ( const char *d, size_t size )
657
bool CFileIO::AppendData ( const char *d, size_t size )
656
{
658
{
657
	std::fstream File(m_sFilename, _append());
659
	std::ofstream File(m_sFilename, _append());
658
	if ( !File.is_open() ) return false;
660
	if ( !File.is_open() ) return false;
659
 
661
 
660
	// move to the end of the file
662
	// move to the end of the file
661
	File.seekg(0, std::ios::end);
663
	//File.seekg(0, std::ios::end);
662
 
664
 
663
	char *pos = (char *)d;
665
	char *pos = (char *)d;
664
	while ( size > 0 ) {
666
	while ( size > 0 ) {
665
		size_t read = 500000;
667
		size_t read = 500000;
666
		if ( read > size ) read = size;
668
		if ( read > size ) read = size;
Line 718... Line 720...
718
{
720
{
719
	if ( m_sFilename.empty() ) return NullString;
721
	if ( m_sFilename.empty() ) return NullString;
720
	return m_sFilename.token(".", -1);
722
	return m_sFilename.token(".", -1);
721
}
723
}
722
 
724
 
-
 
725
Utils::String CFileIO::extension ()
-
 
726
{
-
 
727
	if ( m_sFilename.empty() ) return "";
-
 
728
	return m_sFilename.token(".", -1);
-
 
729
}
-
 
730
 
723
CyString CFileIO::ChangeFileExtension ( CyString ext )
731
CyString CFileIO::ChangeFileExtension ( CyString ext )
724
{
732
{
725
	if ( m_sFilename.empty() )
733
	if ( m_sFilename.empty() )
726
		return NullString;
734
		return NullString;
727
	
735
	
Line 933... Line 941...
933
	if ( !stat(GetWindowsFilename().c_str(), &fileStat) )
941
	if ( !stat(GetWindowsFilename().c_str(), &fileStat) )
934
		return (time_t)fileStat.st_atime;
942
		return (time_t)fileStat.st_atime;
935
#endif
943
#endif
936
	return 0;
944
	return 0;
937
}
945
}
-
 
946
 
-
 
947
size_t CFileIO::position()
-
 
948
{
-
 
949
	return m_fId.tellg();
-
 
950
}
-
 
951
 
938
/**
952
/**
939
 * Copys the contents of a file to another
953
 * Copys the contents of a file to another
940
 *
954
 *
941
 * Reads and writes the files in block
955
 * Reads and writes the files in block
942
 */
956
 */