Update:
I see that this post has gotten a down vote for no apparent reason from the voter (no reply to my post).
That is unfortunate.
If that happened because my tone may offend the OP, it was not my intent at all to offend the OP.
I see the problem of not understanding the idea of "text of filename"->(pointer) to data often with Windows students.
If there is a way to explain it better than I did, then great! Please post!
---original post continues---
Deleted perhaps inflammatory statement.
Your question demonstrates a fundamental lack of understanding of how a file system works.A file does not "exist in a directory" - NO! - that is not what happens!
As a simplification, lets say that a file is just a "block of contiguous bits/bytes on the disk". The disk is a huge block of contiguous bytes from say byte 0 to byte 2,000,000,000. A file may exist from byte 10356 to byte 22356 on the disk.
The directory entry for "c:\ksk\vista\sra.txt" would be a data structure with an association between that text name and a pointer to say byte 10356 as the "start" and this text name would also have a length of 22356-10356+1 bytes associated with it. There would be other properties associated with that text name - this is called a "directory entry" - like the telephone "white pages": name, address, etc.
So if we "rename" sra.txt to SRA_new.txt:
That means that this directory entry text name that associates "c:\ksk\vista\sra.txt" to byte 10356 on the disk changes to "c:\ksk\vista\SRA_new.txt". No data on the disk moves.
If we want to "move" the file to a different directory on the same physical disk drive/file system, no bits in the file are actually "moved"!! NO!! We just create a new entry: "C:\home\sra.txt" to point to byte 10356 and delete the entry for "c:\ksk\vista\sra.txt".
So "moving a file to a different directory on the same disk" is the same as "renaming it"!
Moving a file from one physical disk to another is different. We have to create a directory entry on the other disk, copy the bits from disk1 to disk2, delete the directory entry on disk1, etc.
I am sorry that I got long winded here. But there is NO difference in what happens to the bits on the disk between "changing the name associated with those bits" and "moving those bits to a different directory" - this is just changing the text name associated with the starting byte of the data. |