Advertisement

C library for copying and deleting: easy question

Started by October 30, 2006 08:01 PM
2 comments, last by KulSeran 18 years, 2 months ago
In unix, is there a copy and delete file command, or should I just use "system". I worry about security risks if my program were hacked to abuse the function which deletes a temporary file the game creates.
Have a look at <unistd.h> (unlink()) for a start and here for more.

Copying a file is, as far as I know, typically done by hand (create the target file, copy the data).

For temporary files, you can use tmpfile() from <stdio.h> -- it automatically gets deleted when you close all the FILE* handles.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Quote: Original post by matt_j
the function which deletes a temporary file the game creates.

It sounds like you need to read about the tmpfile function.

EDIT: In my defense, Fruny is a ninja.
CopyFileEx (windows API)
remove (stdio)
tmpfile (stdio)

This topic is closed to new replies.

Advertisement