Results 1 to 5 of 5

Thread: How to create a symlink to a directory?

  1. #1
    ucomesdag Guest

    Exclamation How to create a symlink to a directory?

    As the title says, does anyone know if there is a easy way to create a symlink to a directory with QT 4.2?
    Fore files there is QFile::link(...) but I couldn't find anything for QDir.

    It's giving me a headeach...

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to create a symlink to a directory?

    Hello,

    Well, the QFile::link() method works fine for both files or directories !

    Just tried this for example, /home/gfy is my home directory

    QFile::link("/home/gfy", "/tmp/mylink");

    It creates a link in /tmp, called mylink, and it points to /home/gfy

  3. The following user says thank you to guilugi for this useful post:


  4. #3
    ucomesdag Guest

    Default Re: How to create a symlink to a directory?

    It works, thanks. But not on windows?

  5. #4
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to create a symlink to a directory?

    Well, I don't know, because I was at work, and I have only Debian there...

    Maybe it doesn't work, I'll try it tonight

  6. #5
    ucomesdag Guest

    Default Re: How to create a symlink to a directory?

    I should have RTFM! Anyway this way it works.

    Qt Code:
    1. #ifdef Q_OS_UNIX
    2. QFile::link(sourceDir.absolutePath(), destDir.absolutePath());
    3. #endif
    4.  
    5. #ifdef Q_OS_WIN
    6. QFile::link(sourceDir.absolutePath(), destDir.absolutePath().append(".lnk"));
    7. #endif
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. error in compiling qtopia.....
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 11th January 2007, 09:10
  2. errors while installing Qt4.2 in Linux
    By nimmyj in forum Installation and Deployment
    Replies: 11
    Last Post: 13th December 2006, 11:58
  3. change of ownershiip operation not permaitted while build
    By quickNitin in forum Installation and Deployment
    Replies: 5
    Last Post: 16th May 2006, 12:13
  4. create file in another directory
    By raphaelf in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2006, 10:04
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

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
  •  
Qt is a trademark of The Qt Company.