[fpc-pascal] Re: Problems with moving/renaming file using sysutils.renamefile
Reinier Olislagers
reinierolislagers at gmail.com
Fri Feb 10 13:59:28 CET 2012
On 10-2-2012 13:42, michael.vancanneyt-0Is9KJ9Sb0A at public.gmane.org wrote:
> On Fri, 10 Feb 2012, Reinier Olislagers wrote:
>> On 10-2-2012 13:09, Jonas Maebe wrote:
>> 1. Renaming is not moving???
>> The help says:
>> "RenameFile renames a file from OldName to NewName. The function returns
>> True if successful, False otherwise. Remark: you cannot rename across
>> disks or partitions."
> That is exactly what Jonas said.
>> What does this mean, then?
>> If you rename from e.g. /etc/b to /var/b, (and assuming they're on the
>> same partition), you're moving the files from one directory to another,
>> aren't you?
> No, you are renaming them.
I understand that you might be renaming them from a fs/OS standpoint as
there is no actual file data being transferred... but to the user it has
moved.
>> If you cannot move files between directories at all but only rename
>> them, the remark in the help does not make sense.
> You can move them, if the directories are on the same partition.
Exactly. To the user/programmer it looks as if they've moved (the fs
really moved the pointer to the file data into another part of the tree).
>> Maybe it helps if something like this is put there:
>> "RenameFile renames a file from OldName to NewName. The function returns
>> True if successful, False otherwise. Remark: this function can move
>> and/or rename files from one directory to another, but you cannot rename
>> across disks or partitions."
> It seems to me you are confusing 'moving' and 'renaming'.
I'd welcome a better suggestion for adding to the help file...
> The function just renames. The result may be that the file ends up in
> another directory, i.e. is moved.
Mmm yes. To me that is arguing over semantics. Or maybe we're trying to
say the same thing.
I understand that's the way the underlying filesystem works (on Unixes
at least), but that is not the case everywhere.
E.g. Windows rename command help gives:
Renames a file or files.[...]Note that you cannot specify a new drive or
path for your destination file.
So there, rename (the command at least) does NOT allow you to move files
between directories.
In other words, programmers coming from a Windows background might not
expect that the renamefile command allows "moving" files between
directories on the same partition.
I do understand what Jonas & you meant (and I even understood the point
about not being able to move*cough* rename files across directories from
the help before writing to the list - just erroneously assumed /tmp and
/home were on the same partition).
My point is that it would help to expand the help a bit so that it's
clearer.
Then again, my Delphi-less background may lead me to strange errors such
as these which people with a Delphi history may dismiss ;)
>> 2. What is the function for "properly" moving files in FPC that also
>> moves between partitions, if one exists?
>
> None exists.
Thanks, I feared as much.
Thanks for the help, you 2,
Regards,
Reinier
More information about the fpc-pascal
mailing list