in reply to Re^2: Deleting or unlinking a file
in thread Deleting or unlinking a file
"what actually does unlink do?"
The post by Eliya is very close to the mark. Since we are talking about "unlink", another point is of interest especially if you are ever writing a program that updates software.
This discussion applies to Windows also! A "file" is a collection of data bits on the disk. The directory has a "human readable name" that "points" to those bits. The "open" translates the "human readable name" into a data structure that the file system uses to access the data bits, this is the "filehandle". Once a file is "open", the "name" doesn't matter <- this is important. If the file is open, you can change the name or even delete the name without affecting the data bits!
Its been a while since I wrote a software updater for a continuously running system, but basically the idea is to copy all the important stuff onto the target. Say x.dll would get a temporary name of x_temp.dll. Then, x.dll gets "unlinked". Everyone who has this file "open" and is using it, continues to use it even though it has no "name". Then, x_temp.dll is renamed to x.dll and new requests for "x.dll" will get the updated file. The actual "old x.dll" file bits will get "deleted" when then are no longer in use (everyone using it does a close). "Delete" in this case means to mark that area of the disk as available for other use.
From say the Windows command line, you might see something like >del X, unable to delete file X, file is in use. However the Perl unlink 'X' command will succeed.
the above was just to round out discussion of "what does unlink" do - and it is a bit different than command line "delete". Sounds to me like the most likely thing in OP's scenario is wrong permissions on the directory. Unlink of a read only file is completely ok. Anyway, Perl "unlink" does what a UNIX person would expect, even on Windows.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Deleting or unlinking a file
by Anonymous Monk on Mar 16, 2011 at 00:21 UTC | |
by Marshall (Canon) on Mar 16, 2011 at 01:16 UTC | |
by Anonymous Monk on Mar 16, 2011 at 01:38 UTC | |
by Marshall (Canon) on Mar 16, 2011 at 03:41 UTC |