Results 1 to 4 of 4

Thread: QDir: dealing with folders with special characters

  1. #1
    Join Date
    Jan 2011
    Posts
    55
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QDir: dealing with folders with special characters

    I'm doing a recursive scan of a folder, and noticed that if a folder name is, for example,

    !myfolder

    QDir will replace the "!" with "..", and next loop will try to get to the parent folder, instead of continuing the recursion.

    How are we supposed to deal with folder containing special characters? Thanks

  2. #2
    Join Date
    Sep 2011
    Location
    Buenos Aires
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDir: dealing with folders with special characters

    As i'm still a noob in Qt related things I cant give you a pure Qt solution.
    But if you are already using boost maybe you can use the filesystem library that uses unicode to manage paths, that should get you going even with non ASCII folder names ( for example latin characters like ñ ).

    LInk -> http://www.boost.org/doc/libs/1_47_0.../tutorial.html

  3. #3
    Join Date
    Jan 2011
    Posts
    55
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDir: dealing with folders with special characters

    Quote Originally Posted by slqh View Post
    As i'm still a noob in Qt related things I cant give you a pure Qt solution.
    But if you are already using boost maybe you can use the filesystem library that uses unicode to manage paths, that should get you going even with non ASCII folder names ( for example latin characters like ñ ).

    LInk -> http://www.boost.org/doc/libs/1_47_0.../tutorial.html
    Thanks for that link, will study this...

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QDir: dealing with folders with special characters

    Qt Code:
    1. QDir will replace the "!" with "..", and next loop will try to get to the parent folder, instead of continuing the recursion.
    To copy to clipboard, switch view to plain text mode 
    Please post a minimal, complete example that reproduces this behaviour.

    It clearly doesn't do anything like that here:
    Qt Code:
    1. #include <QtCore>
    2. #include <QDebug>
    3.  
    4. int main(int argc, char** argv)
    5. {
    6. QCoreApplication app(argc, argv);
    7.  
    8. QDir dir;
    9. dir.cd("a");
    10. qDebug() << "Content of a" << dir.entryList();
    11. dir.cd("!b");
    12. qDebug() << "Content of a/!b" << dir.entryList();
    13.  
    14. return 0;
    15. }
    To copy to clipboard, switch view to plain text mode 
    when run:
    Qt Code:
    1. $ find a
    2. 1949745 4 drwxr-xr-x 3 chrisw users 4096 Oct 13 10:01 a
    3. 1949748 0 -rw-r--r-- 1 chrisw users 0 Oct 13 10:01 a/afile
    4. 1949746 4 drwxr-xr-x 2 chrisw users 4096 Oct 13 10:01 a/!b
    5. 1949747 0 -rw-r--r-- 1 chrisw users 0 Oct 13 10:01 a/!b/bfile
    6. $ ./test
    7. Content of a ("!b", ".", "..", "afile")
    8. Content of a/!b (".", "..", "bfile")
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Remap special characters?
    By PaladinKnight in forum Qt Programming
    Replies: 0
    Last Post: 28th September 2010, 07:23
  2. special characters in xml
    By khcbabu in forum Qt Programming
    Replies: 3
    Last Post: 6th November 2008, 23:10
  3. QtXml and special characters
    By supergillis in forum Qt Programming
    Replies: 4
    Last Post: 29th September 2008, 18:44
  4. QT 4 Xml parsing with special characters
    By KrishnaKishan in forum Qt Programming
    Replies: 1
    Last Post: 18th June 2007, 11:53
  5. Using special characters in QT dialogs
    By hvengel in forum Qt Tools
    Replies: 2
    Last Post: 10th April 2007, 01:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.