Hallo Mark,
thank you for your help I tested it and now it works. At first I thought
for what in the hell is it useful but while testing I noticed by an
accident that you can use the syntax also to change the name of the file if
you move it.
Btw. the example in the reference guide chapter 8.24 should to be changed!
Regards
Roger
Von: Mark Miesfeld [mailto:[email protected]]
Gesendet: Samstag, 8. März 2014 19:36 An: Roger Bilau
Betreff: Re: [Oorexx-users] SysFileMove -> access denied
Hi Roger,
This program works, both for moving to the same drive and for moving to to a
different drive.
Your problem was that you were trying to "move" a file to a directory like
you can from the command line with 'move' The move command has its own
internal logic that makes things "easier" for the user.
With SysFileMove() you need to supply that logic yourself.
The 183 return code was because you were trying to move the file to a new
file with the name of an existing directory. You explicitly can not do
that. From the command line using the move command:
move myFile.txt "c:\program files"
Using SysFileMove() would need to be this:
call SysFileMove myFile.txt "C:\Program Files\myFile.txt"
/* moveFile.rex */
filesSrc = 'C:\work.ooRexx\testData\'
--filesDst = 'C:\work.ooRexx\testDst\'
filesDst = 'U:\work.ooRexx\testDst\'
if \ SysIsFileDirectory(filesDst) then do
rc = SysMkDir(filesDst)
if rc <> 0 then do
say 'Failed to create directory' filesDst
return 99
end
end
else do
-- Be sure directory is empty
'del /q' filesDst'\*.*'
end
ret = SysFileTree(filesSrc || '*.*', f., 'FO')
if ret <> 0 then do
say 'SysFileTree error ret:' ret
return 99
end
if f.0 == 0 then do
say 'NO files found'
say 'f.0' f.0
return 99
end
do i = 1 to f.0
fileName = fileSpec('N', f.i)
dstName = filesDst || fileName
say 'SysFileMove('f.i',' dstName')'
call SysFileMove f.i, dstName
ret = result
--ret = SysFileMove(f.i, dstName)
If ret <> 0 then do
say 'Failed to move file' f.i
say 'RC='ret SysGetErrortext(ret)
end
end
return 0
Note also that for call SysFileMove f.i, dstName The result of the call
is stored in RESULT not RC
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Oorexx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-users