locked
POSIX in Metro Apps

    Question

  • Hi Everyone,

    My app is multiplatform written in C++ and therefore uses a lot of POSIX functions for file/directory handling. Will I fail cert if I use POSIX functions like fwrite, fread, fclose, etc? I know Metro is a sandbox system with security enforcement concerning where an app can read/write files/dirs which I am all for. However, I can't use the async Windows::Storage functions for file handling as it would involve a complete rewrite of my application which isn't feasible at this time. I also found these Win32 functions are available to Metro apps which is great: http://msdn.microsoft.com/en-us/library/windows/apps/br205753.aspx

    At least those give me synchronous file IO. Should I only use those Win32 functions?

    I ran my package through WACK but it simply said there were APIs that weren't certified for use in my app with no real details given.

    Thanks Much!

    Anthony

    Monday, May 21, 2012 9:17 PM

Answers

  • It depends on where you are getting those functions from.

    If you are using a C-runtime implemented for Metro style apps (like the one from Visual Studio 11) then you should be fine. If you're using one which isn't implemented for Metro style apps (like the C-runtime from Visual Studio 10) then it won't pass certification.

    If you are doing synchronous file IO I strongly recommend doing it on a worker thread rather than the UI thread so you can keep the UI responsive even if you aren't using async functions.

    --Rob

    • Marked as answer by TheMCP Tuesday, May 22, 2012 1:30 AM
    • Unmarked as answer by TheMCP Tuesday, May 22, 2012 1:30 AM
    • Marked as answer by TheMCP Tuesday, May 22, 2012 1:31 AM
    Monday, May 21, 2012 10:41 PM
    Owner

All replies

  • It depends on where you are getting those functions from.

    If you are using a C-runtime implemented for Metro style apps (like the one from Visual Studio 11) then you should be fine. If you're using one which isn't implemented for Metro style apps (like the C-runtime from Visual Studio 10) then it won't pass certification.

    If you are doing synchronous file IO I strongly recommend doing it on a worker thread rather than the UI thread so you can keep the UI responsive even if you aren't using async functions.

    --Rob

    • Marked as answer by TheMCP Tuesday, May 22, 2012 1:30 AM
    • Unmarked as answer by TheMCP Tuesday, May 22, 2012 1:30 AM
    • Marked as answer by TheMCP Tuesday, May 22, 2012 1:31 AM
    Monday, May 21, 2012 10:41 PM
    Owner
  • Thanks Rob,

    I'm using VS 11 so I should be good there. It's interesting that the directory POSIX functions aren't implemented (makedir, rmdir, etc). Is this due to the heightened folder permissions security in Win 8?

    Also for the thread you mentioned can you point me towards some example code for that? Is this using the task.then functionality in the Concurrency namespace?

    Thanks Again!

    Tuesday, May 22, 2012 1:33 AM