Results 1 to 4 of 4

Thread: QFileDevice::map() returns "Access is denied" after file resize

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2013
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QFileDevice::map() returns "Access is denied" after file resize

    Hello everyone,

    I'm using a memory mapped file through a QFile object and its map() method. Works like a charm so far -- until I'm doing a resize() of the file. After that, map() always results in "Access is denied".

    Maybe I'm doing something wrong, but I've tried every conceivable combination of unmap(), close(), open(), resize(), flush() I could think of. I know that the resize works, since size() reports the correct size after the resize and its size on disk is also correct. unmap() returns true. open() returns true. resize() returns true. But as soon as I want to map() the whole file (we're talking 128kB here), I get an error. I can, however, map() to the original file size... Cache problem or something?! No idea what I'm doing wrong.

    Heres the method with which I try to extend the mmap'd file:

    Qt Code:
    1. void xxx::Extend()
    2. {
    3. file.unmap(mmap);
    4.  
    5. file.resize( file.size() + PAGESIZE );
    6.  
    7. // Doesn't seem to be necessary
    8. file.close();
    9. file.open(QIODevice::ReadWrite);
    10.  
    11. // After this, mmap == nullptr, except parm size of map() is <= original file size
    12. mmap = file.map(0, file.size());
    13.  
    14. // This prints "Access is denied"
    15. qDebug() << file.errorString();
    16. }
    To copy to clipboard, switch view to plain text mode 


    Thanks a lot in advance and best regards!


    Edit: OS is Windows 7 64bit, Qt 5.1.1 and MinGW 4.8.0
    Last edited by Jansemon; 5th November 2013 at 15:41.

Similar Threads

  1. Replies: 5
    Last Post: 15th August 2014, 03:04
  2. libpng "permission denied"
    By RolandHughes in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2013, 17:29
  3. Replies: 3
    Last Post: 15th February 2010, 17:27
  4. Replies: 3
    Last Post: 25th August 2009, 13:03
  5. QLocale::system().name() returns "C" instead of "de"
    By momesana in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2008, 14:59

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.