-// analyse some lines of the file trying to guess it's type.
-// if it fails, it assumes the native type for our platform.
-wxTextFileType wxTextFile::GuessType() const
-{
- // file should be opened and we must be in it's beginning
- wxASSERT( m_file.IsOpened() && m_file.Tell() == 0 );
-
- // scan the file lines
- size_t nUnix = 0, // number of '\n's alone
- nDos = 0, // number of '\r\n'
- nMac = 0; // number of '\r's
-
- // we take MAX_LINES_SCAN in the beginning, middle and the end of file
- #define MAX_LINES_SCAN (10)
- size_t nCount = m_aLines.Count() / 3,
- nScan = nCount > 3*MAX_LINES_SCAN ? MAX_LINES_SCAN : nCount / 3;
-
- #define AnalyseLine(n) \
- switch ( m_aTypes[n] ) { \
- case wxTextFileType_Unix: nUnix++; break; \
- case wxTextFileType_Dos: nDos++; break; \
- case wxTextFileType_Mac: nMac++; break; \
- default: wxFAIL_MSG(_("unknown line terminator")); \
- }