Difference between remove and unlink
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Difference between remove and unlink




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Difference between remove and unlink  
ravi


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-15-04 03:36 PM

What is the difference between unlink() and remove().  Assume i have a
file x and it has a hardlink y.
then what is the difference between
unlink("x");
remove ("x");






[ Post a follow-up to this message ]



    Re: Difference between remove and unlink  
Erik Max Francis


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-15-04 03:36 PM

ravi wrote:

> What is the difference between unlink() and remove().  Assume i have a
> file x and it has a hardlink y.
> then what is the difference between
> unlink("x");
> remove ("x");

unlink deletes files, rmdir deletes directories, remove deletes either.

man unlink
man remove

--
__ Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Then conquer we must, for our cause is just ...
-- Francis Scott Key





[ Post a follow-up to this message ]



    Re: Difference between remove and unlink  
Stephane CHAZELAS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-15-04 03:36 PM

2004-09-15, 00:35(-07), Erik Max Francis:
[...] 
>
> unlink deletes files, rmdir deletes directories, remove deletes either.
[...]

And to do so, remove does a "lstat" on the file to find out if
it's a directory or not. That means that "remove" involves two
system calls (lstat and either unlink or rmdir). You can save
the "lstat" if you know the type of the file by advance by
calling directly unlink or rmdir.

--
Stephane





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:43 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register