Results 1 to 2 of 2

Thread: converting permission numeric code to rwx format

  1. #1
    Join Date
    Jun 2014
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default converting permission numeric code to rwx format

    I have a form having a list widget and a label. I want to display file permission, when I click listwidget having file names got from some filesystem. I used following code :

    Qt Code:
    1. QFile file(strpath);
    2. QFileDevice::Permissions p = file.permissions();
    3. labelpermission->setText(QString::number(p));
    To copy to clipboard, switch view to plain text mode 
    in help manual I got following :-
    Qt Code:
    1. QFileDevice::ReadOwner 0x4000 The file is readable by the owner of the file.
    2. QFileDevice::WriteOwner 0x2000 The file is writable by the owner of the file.
    3. QFileDevice::ExeOwner 0x1000 The file is executable by the owner of the file.
    4. QFileDevice::ReadUser 0x0400 The file is readable by the user.
    5. QFileDevice::WriteUser 0x0200 The file is writable by the user.
    6. QFileDevice::ExeUser 0x0100 The file is executable by the user.
    7. QFileDevice::ReadGroup 0x0040 The file is readable by the group.
    8. QFileDevice::WriteGroup 0x0020 The file is writable by the group.
    9. QFileDevice::ExeGroup 0x0010 The file is executable by the group.
    10. QFileDevice::ReadOther 0x0004 The file is readable by anyone.
    11. QFileDevice::WriteOther 0x0002 The file is writable by anyone.
    12. QFileDevice::ExeOther 0x0001 The file is executable by anyone.
    To copy to clipboard, switch view to plain text mode 
    and when I was in exicuting program prmission was displayed as : 21845 ( for /bin/GET ) or 30581 (for /home/rahul/.netbeans).
    Now I want to display this numeric code in form of "drwxr-xr-x" format. But here is only four fields and in numeric code there are five fields.
    So my question is how to decode this numeric code to rwx code and display in QLabel.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    516
    Thanks
    12
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: converting permission numeric code to rwx format

    Hi, I think you are mixing decimal and hexadecimal numbers. For example 30581 is decimal (base 10). In hex (base 16) it is displayed 0x7775, and that can easily be matched to the QFileDevice numbers like ReadOwner.

    Ginsengelf

Similar Threads

  1. Converting QString to QDateTime with format
    By dantom in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2018, 17:51
  2. Converting __DATE__ to ISO format
    By BobTheProg in forum Qt Programming
    Replies: 9
    Last Post: 9th December 2015, 14:30
  3. Converting DB to code
    By Atomic_Sheep in forum General Programming
    Replies: 1
    Last Post: 23rd August 2013, 13:47
  4. Replies: 5
    Last Post: 1st June 2011, 09:28
  5. converting image into monochrome format
    By aj2903 in forum Qt Programming
    Replies: 2
    Last Post: 13th November 2009, 16:53

Tags for this Thread

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.