title: Open returns (-1) with O_CREAT when file already exists
body: <p>That function saves an unsigned int array in a file. I want it to overwrite an existing file or to create it. If the file doesn't exist, it is filled correctly. If it already exists, it remains as it was : but I want it to be overwritten. That is why I use 'O_CREAT'.</p>
  
  <pre><code>int save_pic(t_bunny_pixelarray *pix, const char *filename, t_tekpaint *tekpaint) {
      unsigned int *pixels;
      int FD;
      int i = 0;
      if (!filename)
          return 1;
      if ((FD = open(filename, O_WRONLY | O_CREAT, S_IRUSR)) == -1)
          return 1;
      return 0;
  }
  </code></pre>
  
  <p>(I write between the last <code>return 1</code> and <code>return 0</code>).</p>
  
  <p>If I do the following :</p>
  
  <pre><code>if ((FD = open(filename, O_WRONLY | O_CREAT, S_IRUSR)) == -1) {
      printf("error\n");                                                            
      return 1;
  }
  </code></pre>
  
  <p>It prints error if files exists, and doesn't print error if file doesn't exist.
  I tried to change <code>S_IRUSR</code> to other possible values for I thought maybe the process had no right on the file or something but it doesn't change anything.</p>
  
  <p>It acts like if I was using <code>O_EXCL</code>, which I obviously don't.
  MUST be a stupid thing.
  Thank you.</p>