(SOLVED) Handling of file path information on Windows / Linux

I want to analyze a file path in an Arduino program on Windows and on Linux (Raspberry Pi), for example to isolate the file name.

  • in Windows the separator is ''
  • In Linux, the separator is '/'.
    How can i identify it? My example: isolate the file name from the specification FILE

The Windows version:

  strcpy(fname,strrchr(__FILE__,'\\') + 1);

The Linux version ???

  strcpy(fname,strrchr(__FILE__,'/') + 1);

Is there a constant like "Operating system" that is usable as an if argument?

The strtok() function allows you to split a string into component parts. You can use both the / and \ as separators in the same call to strtok() if that helps

On Windows your FILE variable will start with "C:" or whatever drive it resides on. On my Mac and I expect on a Pi, it will start "/". So just check whether the first character is '/' to tell you which system it came from.

Hello - thank you both, so I will find a solution with one of your hints!