I’m saving my data in the executable file of the program. I copy it to a temporary file, overwrite a part starting at a ‘magic string’ and rename it to the original. I know this is a bad idea, but I’m doing it just for experimenting.
I got everything to work so far, except for that I have to re-enable “Allow running as an executable” each time the file is replaced. What ways are there to solve this?
Additional information: I use linux.
Advertisement
Answer
If you want to avoid using system(), you can use
#include <sys/stat.h> int chmod(const char *path, mode_t mode);
It is documented in http://linux.die.net/man/3/chmod.
See also: C++ – How to set file permissions (cross platform).