Hi all, I got two simple questions:
1
can anybody tell me the best way on UNIX to remove files and/or directories BUT to test whther they exist beforehand.
Currently I'm using [tt]system("rm filename"[/tt] and [tt]system("rmdir directory"[/tt] - however, I think there must be a way like this:
[tt] if (file exists)
delete it;
if (directory exists and is empty)
delete it;[/tt]
only I don't know how on UNIX.
2
Also, if I kick off another program from within a program, is there any way I can get the PID number easily.
Currently, I'm doing:
[tt]system("./program.out& > output.txt"[/tt]
then examining the contents of 'output.txt' - there must be a better way????
Thanks in advance.
programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.
1
can anybody tell me the best way on UNIX to remove files and/or directories BUT to test whther they exist beforehand.
Currently I'm using [tt]system("rm filename"[/tt] and [tt]system("rmdir directory"[/tt] - however, I think there must be a way like this:
[tt] if (file exists)
delete it;
if (directory exists and is empty)
delete it;[/tt]
only I don't know how on UNIX.
2
Also, if I kick off another program from within a program, is there any way I can get the PID number easily.
Currently, I'm doing:
[tt]system("./program.out& > output.txt"[/tt]
then examining the contents of 'output.txt' - there must be a better way????
Thanks in advance.
programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.