Skip to content

Commit d68a21f

Browse files
committed
Fix .tide not working with 'All Files (*)' since the supportsFiles() implementation wasn't accounting for BOM
1 parent c0f6987 commit d68a21f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/plugins/tbin/tidemapformat.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,13 @@ QString TideMapFormat::shortName() const
558558

559559
bool TideMapFormat::supportsFile(const QString &fileName) const
560560
{
561-
std::ifstream file(fileName.toStdString(), std::ios::in | std::ios::binary);
562-
if (!file)
561+
QFile file( fileName );
562+
if ( !file.exists() || !file.open( QFile::ReadOnly | QFile::Text ) )
563563
return false;
564564

565565
// Not sure what a better way of doing this would be without pre-parsing the entire file...
566-
std::string magic(5, '\0');
567-
file.read(&magic[0], static_cast<std::streamsize>(magic.length()));
566+
QTextStream text( &file );
567+
QString magic = text.read( 5 );
568568

569569
return magic == "<?xml" || magic == "<Map ";
570570
}

0 commit comments

Comments
 (0)