Menu

How to do file input/output?

2018-09-24
2018-09-27
  • Pete Maclean

    Pete Maclean - 2018-09-24

    I am continuing work on QCSSL and focusing on eliminating use of MFC. In one case, MFC is used to load the contents of a file into memory and this brings up the whole question of how we are going to handle file i/o in Hermes. Has there been any discussion of this before? I have not found any with a quick search.

    I see three ways to approach this. One is to reduce all file i/o to POSIX file-access functions. Another is to implement three variations of all file i/o code, one for Windows, one for Linux and one for Mac. And the third is to use some open-source multi-platform file-access library.

    I find none of these three appealing.

    POSIX is ugly, based on 40+ year-old UNIX primitives, has no support (as far as I can determine) for wide-character strings (although they can be managed by extensions), has sniffy support by Microsoft, has a reputation for poor performance, and suffers from having rants all over the Internet saying "POSIX must die!".

    Implementing native file i/o for each system would offer the best perfomance and the clearest semantics but would probably require the most work.

    Using a multi-platform library is what I would do if I were working on my own code but I do not know of an open-source one that would fit. I have not searched far but the only one I have found (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1031r0.pdf) seems way too overblown and complex for our needs (which are really rather simple). Does anyone know of another that might be fitting?

    Of course another option would be to just do everything for Windows at the moment and deal with other platforms later. (Possibly by emulating Windows functions in native code.)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.