QString tmp="file.txt";QFile file(tmp); How do I obtain REAL filename?( FiLe.TxT )
i am on stincking windows. the filename is case insensitive. file.txt = FiLe.tXT
I need to match against a list of case insensitive file names (strings) and determine the real filename that exists in the sistem :
if file.exists("case-insensitive.txt") then tell me file.filename(the real one not case-insensitive)
QString tmp = "file.txt"; //will match FiLe.tXt which is OK
QFile file(tmp);
qDebug()<<file.fileName();
QFileInfo file_info(file);
file_info.absoluteFilePath(); // i want FiLE.tXt not file.txt
how do i obtain the real name that exists in the windows file system ?
Re: QString tmp="file.txt";QFile file(tmp); How do I obtain REAL filename?( FiLe.TxT
I think the easiest solution would be to retrieve the directory the file is in, open it with QDir and use QDir::entryList() to list files in this directory. They will have 'real' names so matching the proper one will be easy (for example using QString::toLower()).
Re: QString tmp="file.txt";QFile file(tmp); How do I obtain REAL filename?( FiLe.TxT
i did:
QDir director("C:\\Documents and Settings\\");
QStringList list ( director.entryList(QDir::Files,QDir::Name) ) ;
list.indexOf( QRegExp( "file.txt" ,Qt::CaseInsensitive) ) //i get the id of the REAL fie
it works, but, is this an ugly/bad way ?
Re: QString tmp="file.txt";QFile file(tmp); How do I obtain REAL filename?( FiLe.TxT
Yes, it's an ugly way, but I doubt there is a better one so you have to stick with it.