Hello! I’m writing a Qt/c++ program that should write and read data on a file, while another process does the same. What file format should I use to prevent conflicts?

  • ENipo@lemmy.world
    link
    fedilink
    arrow-up
    21
    ·
    1 year ago

    No file format will save you by itself since at the end of the day, xml, json, etc they are all plain text.

    One solution would be to use some database (like sqlite if you are just doing things locally on your computer).

    Another solution would be to have a single process that is responsible for writing the data, while all other processes send messages to it via a queue.

      • sip
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        sounds good, but you need to look into races.

        if program A used what it reads to write back and program B writes in the meanwhile A’s work won’t be ok.

        transactions solve this.