[comp.sys.mac.programmer] Move a file from one directory to another.

drew@lethe.UUCP (Drew Sullivan) (05/22/89)

How does a program move a file from one directory to another.

	Rename("\pvol:dir:file", 0, "\pvol:dir2:file");

fails.  I know it can be done, the finder does it.

	Think-C's rename(from, to) should have handled the case
for moving from directory to directory, but it doesn't either.
	
-- 
  -- Drew Sullivan, <drew@lethe.uucp>

tim@hoptoad.uucp (Tim Maroney) (05/27/89)

In article <2638@lethe.UUCP> drew@lethe.UUCP (Drew Sullivan) writes:
>How does a program move a file from one directory to another.
>
>	Rename("\pvol:dir:file", 0, "\pvol:dir2:file");
>
>fails.  I know it can be done, the finder does it.
>
>	Think-C's rename(from, to) should have handled the case
>for moving from directory to directory, but it doesn't either.

Use the PBCatMove function documented in Inside Mac IV-157.  It will move
not only files but directories.  PBRename and PBHRename only change the
name of a file within its current folder.
-- 
Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim
"I am convinced that cross-posting is an evil Satanic plot."
    -- Eugene Miya on soc.net-people, misc.headlines, misc.kids, misc.misc,
		      news.misc, and soc.misc

svc@well.UUCP (Leonard Rosenthol) (05/30/89)

In article <2638@lethe.UUCP>, drew@lethe.UUCP (Drew Sullivan) writes:
> How does a program move a file from one directory to another.
> 
> 	Rename("\pvol:dir:file", 0, "\pvol:dir2:file");
> 
> fails.  I know it can be done, the finder does it.
> 
> 	Think-C's rename(from, to) should have handled the case
> for moving from directory to directory, but it doesn't either.
> 	
	There are two ways of doing a 'move' that I use depending on the
situation.

1) Use PBCatMove (IM IV-157) which will allow you do a DIRECT move from one
directory/folder to another ON THE SAME VOLUME!  If it is possible that the
user will be moving the file across volumes then  you will need to do the
following.

2) Copy the file from A to B and the delete the original.  It may not be the
cleanest thing to do, but it works!


-- 
+--------------------------------------------------+
Leonard Rosenthol        |  GEnie : MACgician
Lazerware, inc.          |  MacNet: MACgician
UUCP: svc@well.UUCP      |  ALink : D0025