SDCard seek

Hi

Here is my code to save data with SDcard ; I can’t overwrite at the begining of the file : only append.
seek seems not working.

any idea ?

thx

      Serial.print(periFile);
      if(fperi=SD.open(periFile,FILE_WRITE)){
        sta=SDOK;
        fperi.seek(0);
        for(i=0;i<PERIRECLEN;i++){fperi.write(periRec[i]);}
        fperi.close();
        Serial.print(" ok ");
      }
      else{sta=SDKO;Serial.print(" ko ");}

Use "O_WRITE" instead of "FILE_WRITE".

pylon:
Use "O_WRITE" instead of "FILE_WRITE".

Thx
Reference mentions only FILE_READ and FILE_WRITE... pls, where can I find informations about other parameters ?

SD lib doesnt like 'O_WRITE' : SD_open said 'false'...

My SD.h (IDE 1.8.9) file contains

#define FILE_READ O_READ
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)

Are you using another library?

No...

I just read Arduino - SD

I will check lib.h files in the future

Thx

SD lib doesnt like 'O_WRITE' : SD_open said 'false'...

Does the target file already exist? If it doesn't, you have to use O_WRITE | O_CREAT.