[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to delete a file??

>> int remove (char *filename);            removes a file
>> int unlink (char *filename);            unlinks a link
>> int rmdir (char *filename);             removes a directory
>What's the differince in "unlinking" and "removing" a file?

Unlink is the same as "remove" for files, and "rmdir" is the same as "remove"
for directories. I guess that internally "remove" just looks at the file type
and calls one
of the other two. "unlink" and "rmdir" are older, they were in early versions of
UNIX, but I
think "remove" is a newer addition.

By "link" in this case, they mean a hard link - every file has at least one hard
link, from where it "is" to its actual data. Removing a link will delete the
data if there are no other links to it. Think of it like reference counting.
(There is a proviso that every open file descriptor also acts like a link in
this case).