On Fri, 10 Feb 2012, Reinier Olislagers wrote:
On 10-2-2012 13:09, Jonas Maebe wrote:
On 10 Feb 2012, at 12:19, Reinier Olislagers wrote:
Trying to move a file (and rename it at the same time):
//ExtractedCompiler is a string variable
//BootstrapCompiler is a string property
//I'm using my own version of debugln, not important here
debugln('Going to rename/move ' + ExtractedCompiler + ' to ' +
BootstrapCompiler);
sysutils.DeleteFile(BootstrapCompiler); //ignore errors
OperationSucceeded:=renamefile(ExtractedCompiler, BootstrapCompiler);
Renaming is not the same as moving. Renaming only works if source and
destination are on the same volume.
Thanks, Jonas.
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.
But not necessarily. On Linux, you see all directories in the same tree.
This does not necessarily mean that they are on the same partition or disk.
This depends on the mount configuration.
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.
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'.
The function just renames. The result may be that the file ends up in
another directory, i.e. is moved.
2. What is the function for "properly" moving files in FPC that also
moves between partitions, if one exists?
None exists.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal