http://qs321.pair.com?node_id=932568


in reply to How to copy/cut and paste files without using modules ?

I just learned I can use unlink to delete files
I think you do not understand how a directory works.

A common misperception is that a file "exists within a directory". No!

A file is a sequence of bits.
A directory entry is a pointer that relates some alphanumeric text to the start of that sequence of bits.

There is a way to have different text values point to the same sequence of bits. Its just that simple.

I am confused as to what you are asking about.

"unlink X;" means literally to disconnect the pointer that the name X describes to a file.

There could be another name 'Y' that points to the same file (which is a sequence of bits on hard disk), 'Y' or 'X' is essentially a starting number of the "nth bit" on the hard drive.

So this does not mean "delete the file" on the disk.

"Unlink" means "disconnect my text pointer to that sequence of bits on the disk".
It is possible for another name to point to the same "file bits".
The storage allocation for the "bits on the disk" will not be freed until there are no more pointers to it in the "directory"

Anyway, please explain your question in more detail!

  • Comment on Re: How to copy/cut and paste files without using modules ?

Replies are listed 'Best First'.
Re^2: How to copy/cut and paste files without using modules ?
by ikegami (Patriarch) on Oct 20, 2011 at 05:58 UTC

    A common misperception is that a file "exists within a directory". No!

    That's a whole lot of BS. Stop pretending that directory entries aren't called files.

    unlink: "Deletes a list of files"
    rm: "Remove files or directories"

    You're trying to correct the OP's terminology, yet he's using the same terminology as Perl and GNU.

      That's a whole lot of BS..... If you are going to say BS then I say nonsense!

      I would prefer that we do not use these terms like BS and nonsense. That is not a civilized discussion.

      A directory entry is a name which points to a "set of bits".
      There can be more than one directory entry that points to the same "set of bits".

      "unlink" means disconnect name "x" to a particular set of bits. In Perl lingo, perhaps you could think of it like deleting a hash key. There could be another hash key which points to the same "value".

      Oh, I'm trying to understand...
      Stop pretending that directory entries aren't called files.
      I said that directory entries are pointers to files.
      Unlink-ing a directory entry does not delete the file.
      It just deletes the pointer to the file.
      In this case, the "file" will be "gone" when all references to it are gone. This is the unix file system link count and similar Perl reference counting.

        I said that directory entries are pointers to files.

        Again, stop pretending that directory entries, the pointers, aren't called files. It's BS. It's nonsense. It's whatever other you'd rather I use instead.

        I know how unlink works. It was totally irrelevant the first time, no less the second.

        I would prefer that we do not use these terms like BS and nonsense. That is not a civilized discussion.

        This is a tough situation.

        On the one hand, you yell at the op:

        A common misperception is that a file "exists within a directory". No!

        But this is exactly how it works, despite the actual implementation details.

        A file exists within a folder, that is why they are called files and folders, this is the model .

        So yes, if you're going to yell at someone and correct someone for using the same model everyone is taught, yes, this is bullshit.