Subversion Repositories spk

Rev

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

Rev 120 Rev 121
Line 13... Line 13...
13
 
13
 
14
CFileIO::CFileIO () : m_lSize(0), m_bBinary(true), m_bAutoDelete(false), m_bSeekP(false)
14
CFileIO::CFileIO () : m_lSize(0), m_bBinary(true), m_bAutoDelete(false), m_bSeekP(false)
15
{
15
{
16
}
16
}
17
 
17
 
18
/*CFileIO::CFileIO(const Utils::String &sFilename, bool bBinary = true) : m_lSize(0), m_bBinary(bBinary), m_bAutoDelete(false)
18
CFileIO::CFileIO(const Utils::String &sFilename, bool bBinary) : m_lSize(0), m_bBinary(bBinary), m_bAutoDelete(false)
19
{
19
{
20
	open(sFilename, bBinary);
20
	open(sFilename, bBinary);
21
}
21
}
22
*/
22
 
23
CFileIO::CFileIO(CyString filename) : m_lSize(0), m_bBinary(true), m_bAutoDelete(false), m_bSeekP(false)
23
CFileIO::CFileIO(CyString filename) : m_lSize(0), m_bBinary(true), m_bAutoDelete(false), m_bSeekP(false)
24
{
24
{
25
	open(filename.ToString(), true);
25
	open(filename.ToString(), true);
26
}
26
}
27
 
27
 
Line 57... Line 57...
57
	m_sFile.removeFirstSpace();
57
	m_sFile.removeFirstSpace();
58
	m_sFile.removeChar(13);
58
	m_sFile.removeChar(13);
59
 
59
 
60
	this->_readFileSize();
60
	this->_readFileSize();
61
	return true;
61
	return true;
62
}
62
}
63
 
63
 
64
unsigned char *CFileIO::read(size_t iAmount)
64
unsigned char *CFileIO::read(size_t iAmount)
65
{
65
{
66
	if ( !this->isOpened() ) startRead();
66
	if ( !this->isOpened() ) startRead();
67
	if ( !this->isOpened() ) return NULL;
67
	if ( !this->isOpened() ) return NULL;
68
 
68
 
Line 72... Line 72...
72
	try {
72
	try {
73
		data = new unsigned char[iAmount + 1];
73
		data = new unsigned char[iAmount + 1];
74
	}
74
	}
75
	catch (std::exception &e) {
75
	catch (std::exception &e) {
76
		CLog::logf(CLog::Log_IO, 2, "ERROR: CFileIO::read(size_t) unable to malloc data, %d (%s)", iAmount + 1, e.what());
76
		CLog::logf(CLog::Log_IO, 2, "ERROR: CFileIO::read(size_t) unable to malloc data, %d (%s)", iAmount + 1, e.what());
77
		return NULL;
77
		return NULL;
78
	}
78
	}
79
 
79
 
80
	if ( !read(data, iAmount, true) ) {
80
	if ( !read(data, iAmount, true) ) {
81
		CLog::logf(CLog::Log_IO, 2, "ERROR: CFileIO::read(size_t) unable to read data from file, %s/%d", m_sFilename.c_str(), iAmount);
81
		CLog::logf(CLog::Log_IO, 2, "ERROR: CFileIO::read(size_t) unable to read data from file, %s/%d", m_sFilename.c_str(), iAmount);
82
		delete data;
82
		delete data;
Line 129... Line 129...
129
 
129
 
130
	return !m_fId.bad();
130
	return !m_fId.bad();
131
}
131
}
132
 
132
 
133
bool CFileIO::WritePartFile ( size_t *offsets, size_t numOffset )
133
bool CFileIO::WritePartFile ( size_t *offsets, size_t numOffset )
134
{
134
{
135
	if ( NoFile() )	return false;
135
	if ( NoFile() )	return false;
136
 
136
 
137
	std::fstream File(m_sFilename, _in());
137
	std::fstream File(m_sFilename, _in());
138
	if ( !File.is_open() ) return false;
138
	if ( !File.is_open() ) return false;
139
 
139
 
140
	// first find file size
140
	// first find file size
141
	File.seekg(0, std::ios::end);
141
	File.seekg(0, std::ios::end);
142
	size_t fullsize = File.tellg(), size = fullsize;
142
	size_t fullsize = static_cast<size_t>(File.tellg()), size = fullsize;
143
	File.seekg(0, std::ios::beg);
143
	File.seekg(0, std::ios::beg);
144
 
144
 
145
	std::fstream writeFile(CPackages::tempDirectory() + "/temp.tmp", _out());
145
	std::fstream writeFile(CPackages::tempDirectory() + "/temp.tmp", _out());
146
	if ( !File.is_open() ) {
146
	if ( !File.is_open() ) {
147
		File.close();
147
		File.close();
Line 151... Line 151...
151
	size_t off = 0;
151
	size_t off = 0;
152
	size_t startPos = 0;
152
	size_t startPos = 0;
153
	size_t remainingSize = fullsize;
153
	size_t remainingSize = fullsize;
154
 
154
 
155
	while ( off < numOffset ) {
155
	while ( off < numOffset ) {
156
		startPos = File.tellg();
156
		startPos = static_cast<size_t>(File.tellg());
157
		size_t offset = offsets[off++];
157
		size_t offset = offsets[off++];
158
		size_t size = offset - startPos;
158
		size_t size = offset - startPos;
159
		try {
159
		try {
160
			char *data = new char[size];
160
			char *data = new char[size];
161
			File.read(data, size);
161
			File.read(data, size);
Line 220... Line 220...
220
 
220
 
221
	std::fstream file(m_sFilename, (m_bBinary) ? (std::ios::in | std::ios::binary) : (std::ios::in));
221
	std::fstream file(m_sFilename, (m_bBinary) ? (std::ios::in | std::ios::binary) : (std::ios::in));
222
	if ( !file.is_open() ) return;
222
	if ( !file.is_open() ) return;
223
 
223
 
224
	file.seekg(0, std::ios::end);
224
	file.seekg(0, std::ios::end);
225
	m_lSize = file.tellg();
225
	m_lSize = static_cast<size_t>(file.tellg());
226
	file.close();
226
	file.close();
227
}
227
}
228
 
228
 
229
bool CFileIO::WipeFile()
229
bool CFileIO::WipeFile()
230
{
230
{
Line 360... Line 360...
360
}
360
}
361
 
361
 
362
bool CFileIO::writeString ( const Utils::String &data )
362
bool CFileIO::writeString ( const Utils::String &data )
363
{
363
{
364
	return WriteData ( data.c_str(), data.length() );
364
	return WriteData ( data.c_str(), data.length() );
365
}
365
}
366
 
366
 
367
bool CFileIO::Exists(const Utils::String &filename)
367
bool CFileIO::Exists(const Utils::String &filename)
368
{
368
{
369
	std::fstream File(filename, std::ios::in | std::ios::binary);
369
	std::fstream File(filename, std::ios::in | std::ios::binary);
370
	bool bRet = File.good();
370
	bool bRet = File.good();
371
	File.close();
371
	File.close();
Line 589... Line 589...
589
	va_list args;
589
	va_list args;
590
	va_start(args, buf);
590
	va_start(args, buf);
591
	bool ret = this->_write((char *)buf, args);
591
	bool ret = this->_write((char *)buf, args);
592
	va_end(args);
592
	va_end(args);
593
	return ret;
593
	return ret;
594
}
594
}
595
 
595
 
596
void CFileIO::_seek(int iPos, int iFrom)
596
void CFileIO::_seek(int iPos, int iFrom)
597
{
597
{
598
	if ( !this->isOpened() ) {
598
	if ( !this->isOpened() ) {
599
		if ( !this->startRead() ) return;
599
		if ( !this->startRead() ) return;
600
	}
600
	}
601
	if ( m_bSeekP ) m_fId.seekp(iPos, iFrom);
601
	if ( m_bSeekP ) m_fId.seekp(iPos, iFrom);
602
	else m_fId.seekg(iPos, iFrom);
602
	else m_fId.seekg(iPos, iFrom);
603
}
603
}
604
 
604
 
605
void CFileIO::seek(unsigned int iPos)
605
void CFileIO::seek(unsigned int iPos)
606
{
606
{
607
	_seek(iPos, std::ios::cur);
607
	_seek(iPos, std::ios::cur);
608
}
608
}
609
 
609
 
610
void CFileIO::seekEnd(unsigned int iPos)
610
void CFileIO::seekEnd(unsigned int iPos)
611
{
611
{
612
	_seek(iPos, std::ios::end);
612
	_seek(iPos, std::ios::end);
613
}
613
}
614
 
614
 
615
void CFileIO::seekStart(unsigned int iPos)
615
void CFileIO::seekStart(unsigned int iPos)
616
{
616
{
617
	_seek(iPos, std::ios::beg);
617
	_seek(iPos, std::ios::beg);
618
}
618
}
619
 
619
 
620
std::fstream &CFileIO::stream()
620
std::fstream &CFileIO::stream()
621
{
621
{
622
	return m_fId;
622
	return m_fId;
623
}
623
}
624
 
624
 
625
bool CFileIO::isOpened() const
625
bool CFileIO::isOpened() const
626
{
626
{
627
	if ( m_fId.is_open() )
627
	if ( m_fId.is_open() )
628
		return true;
628
		return true;
629
	return false;
629
	return false;
630
}
630
}
631
 
631
 
632
void CFileIO::close()
632
void CFileIO::close()
633
{
633
{
634
	if ( this->isOpened() ) m_fId.close();
634
	if ( this->isOpened() ) m_fId.close();
635
	this->_readFileSize();
635
	this->_readFileSize();
636
}
636
}
637
 
637
 
638
int CFileIO::readSize()
638
int CFileIO::readSize()
639
{
639
{
640
	unsigned char size[4];
640
	unsigned char size[4];
641
	if ( this->read(size, 4) ) return (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
641
	if ( this->read(size, 4) ) return (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
642
	return 0;
642
	return 0;
643
}
643
}
644
 
644
 
645
bool CFileIO::atEnd() const
645
bool CFileIO::atEnd() const
646
{
646
{
647
	if ( !this->isOpened() ) return true;
647
	if ( !this->isOpened() ) return true;
648
	if ( m_fId.eof() )		 return true;
648
	if ( m_fId.eof() )		 return true;
649
	return false;
649
	return false;
650
}
650
}
651
 
651
 
652
bool CFileIO::appendFile ( const Utils::String &filename )
652
bool CFileIO::appendFile ( const Utils::String &filename )
653
{
653
{
654
	std::fstream fromFile(filename, _in());
654
	std::fstream fromFile(filename, _in());
655
	if ( !fromFile.is_open() ) return false;
655
	if ( !fromFile.is_open() ) return false;
656
 
656
 
657
	std::fstream toFile(m_sFilename, _append());
657
	std::fstream toFile(m_sFilename, _append());
658
	if ( !toFile.is_open() ) {
658
	if ( !toFile.is_open() ) {
659
		fromFile.close();
659
		fromFile.close();
660
		return false;
660
		return false;
661
	}
661
	}
662
 
662
 
663
	// move to the end of the file
663
	// move to the end of the file
664
	toFile.seekg(0, std::ios::end);
664
	toFile.seekg(0, std::ios::end);
665
 
665
 
666
	// get size of file
666
	// get size of file
667
	fromFile.seekg(0, std::ios::end);
667
	fromFile.seekg(0, std::ios::end);
668
	size_t size = fromFile.tellg();
668
	size_t size = static_cast<size_t>(fromFile.tellg());
669
	fromFile.seekg(0, std::ios::beg);
669
	fromFile.seekg(0, std::ios::beg);
670
 
670
 
671
	char data[500000];
671
	char data[500000];
672
	while ( size > 0 )
672
	while ( size > 0 )
673
	{
673
	{
Line 700... Line 700...
700
	// move to the end of the file
700
	// move to the end of the file
701
	toFile.seekg(0, std::ios::end);
701
	toFile.seekg(0, std::ios::end);
702
 
702
 
703
	// get size of file
703
	// get size of file
704
	fromFile.seekg(0, std::ios::end);
704
	fromFile.seekg(0, std::ios::end);
705
	size_t size = fromFile.tellg();
705
	size_t size = static_cast<size_t>(fromFile.tellg());
706
	fromFile.seekg(0, std::ios::beg);
706
	fromFile.seekg(0, std::ios::beg);
707
 
707
 
708
	char data[500000];
708
	char data[500000];
709
	while ( size > 0 )
709
	while ( size > 0 )
710
	{
710
	{
711
		size_t read = 500000;
711
		size_t read = 500000;
712
		if ( read > size )
712
		if ( read > size )
713
			read = size;
713
			read = size;
714
 
714
 
715
		size -= read;
715
		size -= read;
716
 
716
 
717
		fromFile.read(data, read);
717
		fromFile.read(data, read);
718
		toFile.write(data, read);
718
		toFile.write(data, read);
719
	}
719
	}
720
 
720
 
721
	fromFile.close();
721
	fromFile.close();
722
	toFile.close();
722
	toFile.close();
723
	return true;
723
	return true;
724
}
724
}
725
 
725
 
726
 
726
 
727
bool CFileIO::AppendData ( const char *d, size_t size )
727
bool CFileIO::AppendData ( const char *d, size_t size )
728
{
728
{
729
	std::ofstream File(m_sFilename, _append());
729
	std::ofstream File(m_sFilename, _append());
730
	if ( !File.is_open() ) return false;
730
	if ( !File.is_open() ) return false;
731
 
731
 
732
	// move to the end of the file
732
	// move to the end of the file
733
	//File.seekg(0, std::ios::end);
733
	//File.seekg(0, std::ios::end);
734
 
734
 
735
	char *pos = (char *)d;
735
	char *pos = (char *)d;
736
	while ( size > 0 ) {
736
	while ( size > 0 ) {
737
		size_t read = 500000;
737
		size_t read = 500000;
738
		if ( read > size ) read = size;
738
		if ( read > size ) read = size;
739
 
739
 
740
		size -= read;
740
		size -= read;
741
 
741
 
742
		try {
742
		try {
743
			File.write(pos, read);
743
			File.write(pos, read);
744
		} 
744
		} 
Line 791... Line 791...
791
	if ( m_sFilename.empty() ) return NullString;
791
	if ( m_sFilename.empty() ) return NullString;
792
	return m_sFilename.token(".", -1);
792
	return m_sFilename.token(".", -1);
793
}
793
}
794
 
794
 
795
Utils::String CFileIO::extension ()
795
Utils::String CFileIO::extension ()
796
{
796
{
797
	if ( m_sFilename.empty() ) return Utils::String::Null();
797
	if ( m_sFilename.empty() ) return Utils::String::Null();
798
	return m_sFilename.token(".", -1);
798
	return m_sFilename.token(".", -1);
799
}
799
}
800
 
800
 
801
CyString CFileIO::ChangeFileExtension ( CyString ext )
801
CyString CFileIO::ChangeFileExtension ( CyString ext )
802
{
802
{
803
	if ( m_sFilename.empty() )
803
	if ( m_sFilename.empty() )
804
		return NullString;
804
		return NullString;
805
	
805
	
806
	return m_sFilename.tokens(".", 1, -2) + "." + ext.ToString();
806
	return m_sFilename.tokens(".", 1, -2) + "." + ext.ToString();
807
}
807
}
808
 
808
 
809
bool CFileIO::Remove(const Utils::String &rem)
809
bool CFileIO::Remove(const Utils::String &rem)
810
{
810
{
811
	//if ( !Exists() ) return false;
811
	//if ( !Exists() ) return false;
812
	return (std::remove(rem) == 0) ? true : false;
812
	return (std::remove(rem) == 0) ? true : false;
813
}
813
}
814
 
814
 
815
bool CFileIO::remove()
815
bool CFileIO::remove()
816
{
816
{
817
	if ( this->isOpened() ) this->close();
817
	if ( this->isOpened() ) this->close();
818
	if ( !this->exists() ) return false;
818
	if ( !this->exists() ) return false;
819
	if ( std::remove(m_sFilename.c_str()) == 0 ) return true;
819
	if ( std::remove(m_sFilename.c_str()) == 0 ) return true;
820
	return false;
820
	return false;
821
}
821
}
822
 
822
 
823
bool CFileIO::WriteFileUTF(std::vector<CyString> *lines)
823
bool CFileIO::WriteFileUTF(std::vector<CyString> *lines)
824
{
824
{
825
	if ( !lines || m_sFilename.empty() )
825
	if ( !lines || m_sFilename.empty() )
826
		return false;
826
		return false;
827
 
827
 
828
	// we need to create the directory
828
	// we need to create the directory
829
	if ( !m_sDirIO.Exists() )
829
	if ( !m_sDirIO.exists() )
-
 
830
	{
-
 
831
		if ( !m_sDirIO.Create() )
-
 
832
			return false;
-
 
833
	}
-
 
834
 
-
 
835
#ifdef _WIN32
-
 
836
	TCHAR buf[5000];
-
 
837
	wsprintf(buf, L"%hs", m_sFilename.c_str());
-
 
838
	FILE *id = _wfopen(buf, L"wt+,ccs=UTF-8");
-
 
839
	if ( !id )
-
 
840
		return false;
-
 
841
 
-
 
842
	// write the rest
-
 
843
	for ( int i = 0; i < (int)lines->size(); i++ )
-
 
844
	{
-
 
845
		CyString l = lines->at(i);
-
 
846
		if ( l.IsIn('\n') )
-
 
847
		{
-
 
848
			int max;
-
 
849
			CyString *strs = l.SplitToken("\n", &max);
-
 
850
			if ( strs && max )
-
 
851
			{
-
 
852
				for ( int i = 0; i < max; i++ )
-
 
853
				{
-
 
854
					CyString line = strs[i];
-
 
855
					line += "\n";
-
 
856
					int size = wsprintf(buf, L"%hs", line.c_str());
-
 
857
					fwrite(buf, sizeof(TCHAR), wcslen(buf), id);
-
 
858
				}
-
 
859
 
-
 
860
				CLEANSPLIT(strs, max);
-
 
861
			}
-
 
862
		}
-
 
863
		else
-
 
864
		{
-
 
865
			l += "\n";
-
 
866
			int size = wsprintf(buf, L"%hs", l.c_str());
-
 
867
			fwrite(buf, sizeof(TCHAR), wcslen(buf), id);
-
 
868
		}
-
 
869
	}
-
 
870
 
-
 
871
	fclose(id);
-
 
872
 
-
 
873
	return true;
-
 
874
#else
-
 
875
    //TODO: write utf8 file writing function
-
 
876
    return false;
-
 
877
#endif
-
 
878
}
-
 
879
 
-
 
880
bool CFileIO::writeFileUTF(std::vector<Utils::String> *lines)
-
 
881
{
-
 
882
	if (!lines || m_sFilename.empty())
-
 
883
		return false;
-
 
884
 
-
 
885
	// we need to create the directory
-
 
886
	if (!m_sDirIO.exists())
830
	{
887
	{
831
		if ( !m_sDirIO.Create() )
888
		if (!m_sDirIO.Create())
832
			return false;
889
			return false;
833
	}
890
	}
834
 
891
 
835
#ifdef _WIN32
892
#ifdef _WIN32
836
	TCHAR buf[5000];
893
	TCHAR buf[5000];
837
	wsprintf(buf, L"%hs", m_sFilename.c_str());
894
	wsprintf(buf, L"%hs", m_sFilename.c_str());
838
	FILE *id = _wfopen(buf, L"wt+,ccs=UTF-8");
895
	FILE *id = _wfopen(buf, L"wt+,ccs=UTF-8");
839
	if ( !id )
896
	if (!id)
840
		return false;
897
		return false;
841
 
898
 
842
	// write the rest
899
	// write the rest
843
	for ( int i = 0; i < (int)lines->size(); i++ )
900
	for(auto itr = lines->begin(); itr != lines->end(); itr++)
844
	{
901
	{
845
		CyString l = lines->at(i);
902
		Utils::String l = (*itr);
846
		if ( l.IsIn('\n') )
903
		if (l.isin('\n'))
847
		{
904
		{
848
			int max;
905
			int max;
849
			CyString *strs = l.SplitToken("\n", &max);
906
			Utils::String *strs = l.tokenise("\n", &max);
850
			if ( strs && max )
907
			if (strs && max)
851
			{
908
			{
852
				for ( int i = 0; i <; max; i++ )
909
				for (int i = 0; i <; max; i++)
853
				{
910
				{
854
					CyString line = strs[i];
911
					Utils::String line = strs[i];
855
					line += "\n";
912
					line += "\n";
856
					int size = wsprintf(buf, L"%hs", line.c_str());
913
					int size = wsprintf(buf, L"%hs", line.c_str());
857
					fwrite(buf, sizeof(TCHAR), wcslen(buf), id);
914
					fwrite(buf, sizeof(TCHAR), wcslen(buf), id);
858
				}
915
				}
859
 
916
 
Line 870... Line 927...
870
 
927
 
871
	fclose(id);
928
	fclose(id);
872
 
929
 
873
	return true;
930
	return true;
874
#else
931
#else
875
    //TODO: write utf8 file writing function
932
	//TODO: write utf8 file writing function
876
    return false;
933
	return false;
877
#endif
934
#endif
878
}
935
}
879
 
936
 
880
bool CFileIO::WriteFile(std::vector<CyString> *lines)
937
bool CFileIO::WriteFile(std::vector<CyString> *lines)
881
{
938
{
882
	if ( !lines || m_sFilename.empty() )
939
	if ( !lines || m_sFilename.empty() )
883
		return false;
940
		return false;
884
 
941
 
885
	// we need to create the directory
942
	// we need to create the directory
886
	if ( !m_sDirIO.Exists() )
943
	if ( !m_sDirIO.exists() )
887
	{
944
	{
888
		if ( !m_sDirIO.Create() )
945
		if ( !m_sDirIO.Create() )
889
			return false;
946
			return false;
890
	}
947
	}
891
 
948
 
Line 904... Line 961...
904
 
961
 
905
	return true;
962
	return true;
906
}
963
}
907
 
964
 
908
bool CFileIO::WriteFile(CyStringList *lines)
965
bool CFileIO::WriteFile(CyStringList *lines)
909
{
966
{
910
	if ( !lines || m_sFilename.empty() )
967
	if ( !lines || m_sFilename.empty() )
911
		return false;
968
		return false;
912
 
969
 
913
	// we need to create the directory
970
	// we need to create the directory
914
	if ( !m_sDirIO.Exists() )
971
	if ( !m_sDirIO.exists() )
915
	{
972
	{
916
		if ( !m_sDirIO.Create() )
973
		if ( !m_sDirIO.Create() )
917
			return false;
974
			return false;
918
	}
975
	}
919
 
976
 
920
	std::ofstream out(m_sFilename.c_str());
977
	std::ofstream out(m_sFilename.c_str());
921
	if ( !out )
978
	if ( !out )
922
		return false;
979
		return false;
923
 
980
 
924
	/*
981
	/*
925
	if ( utf )
982
	if ( utf )
926
	{
983
	{
927
		unsigned char smarker[4];
984
		unsigned char smarker[4];
928
		smarker[0] = 0xEF;
985
		smarker[0] = 0xEF;
929
		smarker[1] = 0xBB;
986
		smarker[1] = 0xBB;
930
		smarker[2] = 0xBF;
987
		smarker[2] = 0xBF;
931
		smarker[3] = 0x00;
988
		smarker[3] = 0x00;
932
 
989
 
933
		out << smarker;
990
		out << smarker;
934
	}
991
	}
935
*/
992
*/
936
	for ( int i = 0; i < (int)lines->Count(); i++ )
993
	for ( int i = 0; i < (int)lines->Count(); i++ )
937
	{
994
	{
938
		CyString l = lines->StringAt(i);
995
		CyString l = lines->StringAt(i);
939
		out << l.c_str() << std::endl;
996
		out << l.c_str() << std::endl;
940
	}
997
	}
-
 
998
 
-
 
999
	out.close();
-
 
1000
 
-
 
1001
	return true;
-
 
1002
}
-
 
1003
 
-
 
1004
bool CFileIO::writeFile(std::vector<Utils::String> *lines)
-
 
1005
{
-
 
1006
	if (!lines || m_sFilename.empty())
-
 
1007
		return false;
-
 
1008
 
-
 
1009
	// we need to create the directory
-
 
1010
	if (!m_sDirIO.exists())
-
 
1011
	{
-
 
1012
		if (!m_sDirIO.Create())
-
 
1013
			return false;
-
 
1014
	}
-
 
1015
 
-
 
1016
 
-
 
1017
	std::ofstream out(m_sFilename.c_str());
-
 
1018
	if (!out)
-
 
1019
		return false;
-
 
1020
 
-
 
1021
	for (auto itr = lines->begin(); itr != lines->end(); itr++)
-
 
1022
		out << (*itr).c_str() << std::endl;
-
 
1023
 
-
 
1024
	out.close();
-
 
1025
 
-
 
1026
	return true;
-
 
1027
}
-
 
1028
 
-
 
1029
bool CFileIO::writeFile(Utils::CStringList *lines)
-
 
1030
{
-
 
1031
	if (!lines || m_sFilename.empty())
-
 
1032
		return false;
-
 
1033
 
-
 
1034
	// we need to create the directory
-
 
1035
	if (!m_sDirIO.exists())
-
 
1036
	{
-
 
1037
		if (!m_sDirIO.Create())
-
 
1038
			return false;
-
 
1039
	}
-
 
1040
 
-
 
1041
	std::ofstream out(m_sFilename.c_str());
-
 
1042
	if (!out)
-
 
1043
		return false;
-
 
1044
 
-
 
1045
	for(auto itr = lines->begin(); itr != lines->end(); itr++)
-
 
1046
		out << (*itr)->str.c_str() << std::endl;
941
 
1047
 
942
	out.close();
1048
	out.close();
943
 
1049
 
944
	return true;
1050
	return true;
945
}
1051
}
Line 1014... Line 1120...
1014
	return 0;
1120
	return 0;
1015
}
1121
}
1016
 
1122
 
1017
size_t CFileIO::position()
1123
size_t CFileIO::position()
1018
{
1124
{
1019
	return m_fId.tellg();
1125
	return static_cast<size_t>(m_fId.tellg());
1020
}
1126
}
1021
 
1127
 
1022
/**
1128
/**
1023
 * Copys the contents of a file to another
1129
 * Copys the contents of a file to another
1024
 *
1130
 *