| J de Boyne Pollard 2007-10-26, 7:11 pm |
| JHT> I am working on an application that can transfer a file
JHT> over a potentially slow link and, when the transfer has
JHT> successfully completed, copies the file from a
JHT> temporary file that was created for this purpose to its
JHT> final destination. I am using the rename() function to
JHT> do this final step.
That's a move, not a copy.
JHT> I have read in "Advanced Unix Programming" by Marc
JHT> Rochkind that rename will not work if the source and
JHT> destination reside on different file systems. [...]
JHT> [...] my intention is to have my own function detect
JHT> this by calling statvfs() for the source name and the
JHT> name of the parent in the destination and comparing
JHT> the f_fsid member of the resulting structures. [...]
Why make life so hard for yourself? Put the temporary file in the
same directory as the final location, and stop worrying about
different filesystems. If renaming a file from one name to another
within a single directory would cross filesystems, then you are
probably using something very unusual (such as stacked filesystems)
and as such probably have other, more serious, design issues to
contend with first. (-:
|