





shuiend wrote:Well i got sending and recieving the file working hopefully. Now I have a question about the syscall() function. We need to be able to remove a file from a program. How would we do that? There is no syscall() function for rm. only for rmdir and i dont know how to use that so that you can remove all files inside the directory which would work. Or if there is another way to remove a file from a program that would be helpfull.


Most good C programmers would frown on cheating with system calls for several reasons. Why call a system command when the system command is going to do the same thing you would do with unlink()/rmdir()? It introduces possible security issues, possible memory issues, it has to spawn a child process, have to assume the location of the command or write code to search for it, etc, etc.
On some systems `unlink' can be used to delete the name of a
directory. On others, it can be used that way only by a privileged
user. In the GNU system `unlink' can never delete the name of a
directory.

ZiaTioN wrote:As far as being root to use unlink() function, this is the way Perl is and the way C is on some systems.
On some systems `unlink' can be used to delete the name of a
directory. On others, it can be used that way only by a privileged
user. In the GNU system `unlink' can never delete the name of a
directory.
Oh and you can also use remove() function but this function simply uses the unlink() function for files and the rmdir() function for directories.

Users browsing this forum: No registered users and 2 guests