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.
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).
If you include stdlib.h
, you can use system("command")
.
Try it:
system("chmod 755 yourExeFile")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With