![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2004
Posts: 8
Rep Power: 0
![]() |
Howdy,
I am looking for a command that would be able to delete a text file in a UNIX directory from a C application. Is there anyway to do this? Thanks for your help, Willz99ta |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Sep 2004
Posts: 38
Rep Power: 0
![]() |
'unlink' is what you want.
Note that this decrements the link count on a file, so if there are multiple hardlinks to that file for some reason this will not delete it. Also if a process has the file open when you unlink it the directory entry will be removed but the file itself will continue to exist while the process has it open. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2004
Posts: 8
Rep Power: 0
![]() |
So this would delete the physical file in a UXIX directory, like the remove command does in ANSI-C?
Thanks for your help, Willz99ta |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Sep 2004
Posts: 38
Rep Power: 0
![]() |
Yeah 'unlink' is a unix syscall to remove files. 'remove' will do the exact same thing, it calls 'unlink' if the specified path is a file and 'rmdir' (another syscall) if the specified path is a directory.
|
|
|
|
|
|
#5 |
|
Expert Programmer
|
Type this on command line:
man 2 unlink You will get all the details you need in using it.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|