Hi
Does anyone has a tip to how to use copy32.exe from within OI.
I need to copy some OS files from one server to another.
Regards
Bertil Ström
Bertil,
What is copy32.exe?
To copy a set of files I would do the following:
- Establish a list of files to copy, e.g with DirList
- Convert the list into a CrLf-delimited string of copy- or xcopy-commands
- Write those commands to a text file with a .bat extension
- Run that bat file with Utility RUNWIN
- Be annoyed. Annoyed with having that ugly MS-DOS window on the screen. Annoyed with commands and possible error messages just flickering by. Annoyed there is no chance for the program to check if each file copy succeeded. (I guess all these problems can be circumvented, but workarounds are annoying too.)
Vennlig hilsen
- Oystein -
[notag]Hi Oystein,
What about the OSOpen, OSBWrite etc commands in Basic+? You could write a routine to do this copy stuff for you and them at least you'd get all the error messages.
This is a function I wrote ages ago:
[<pre>
Compile Subroutine Dos_Copy(CharStr SourceFile, CharStr TargetFile, CharStr Error)
$Insert Logical Equ Bytes$ To 32000 Offset = 0 WriteError = False$ Error = "" * Check for Wildcards If Index(SourceFile,"*",1) Or Index(SourceFile,"?",1) Or Index(TargetFile,"*",1) Or Index(TargetFile,"*",1) Then Error = "Error: Wildcard characters are not allowed" End If Len(Error) Else OsOpen SourceFile To hFileSource Then OsOpen TargetFile To hFileTarget Else OsWrite "" On TargetFile If Status() Then Error = "Error creating " : TargetFile End Else OsOpen TargetFile To hFileTarget Else Error = "Error: Could not Open " : TargetFile End End End If Len(Error) Else Loop DosRec = "" If Len(Error) Else OsBRead DosRec From hFileSource At Offset Length Bytes$ If Status() Then Error = "Error reading " : SourceFile End End While DosRec OsBWrite DosRec On hFileTarget At Offset If Status() Then Error = "Error writing to " : TargetFile DosRec = "" WriteError = 1 End Else Offset += Bytes$ End Repeat OsClose hFileTarget If Status() Then Error = "Error closing " : TargetFile End Else If WriteError Then OsDelete TargetFile End End End OsClose hFileSource If Status() Then Error := "Error closing " : SourceFile End End Else Error = "Error opening " : SourceFile End EndReturn
</pre>]
[<A HREF="http://www.sprezzatura.com" onMouseOver="window.status='Click here to visit our web site?';return(true)">The Sprezzatura Group</A>]
[<I>World Leaders in all things RevSoft</I>]
[<img src="http://www.sprezzatura.com/zz.gif">]
[<script language="javascript">function openNewPage () {window.location.href=(document.TOCNavigator.pageToGoTo.options[document.TOCNavigator.pageToGoTo.selectedIndex].value);document.TOCNavigator.pageToGoTo.selectedIndex="0";}end hiding from non-JS browsers –></script>] [<FORM ACTION "" METHOD=GET NAME="TOCNavigator" <SELECT NAME="pageToGoTo" SIZE=1 onChange="openNewPage()"> <OPTION>Pull down this menu to choose whereabouts on the Sprezz site to go <OPTION VALUE="http://www.sprezzatura.com">Home Page <OPTION VALUE="http://www.sprezzatura.com/whatsnew.htm">What's New <OPTION VALUE="http://www.sprezzatura.com/senl.htm">SENL <OPTION VALUE="http://www.sprezzatura.com/patches.htm">Download S/LIST <OPTION VALUE="mailto:[email protected]">Send mail to support at Sprezzatura <OPTION VALUE="mailto:[email protected]">Send mail to sales at Sprezzatura </SELECT> </FORM>][/notag] </QUOTE> —- === At 10 FEB 2000 04:55AM Oystein Reigem wrote: === <QUOTE>Mr Group, I thought there was a reason for not copying files that way. Does it work on binary files? It won't stop when it hits ctrl-Z or something? Excuse my ignorance. - Oystein - </QUOTE> —- === At 10 FEB 2000 05:00AM The Sprezzatura Group wrote: === <QUOTE>[notag]No, it copies as many bytes as you tell it to or as many as it can get. I've never had a problem with these functions and use them to copy allsorts of things, including DLL's and EXE's. The only problem is it changes the date and timestamp on the file. Regards [<A HREF="http://www.sprezzatura.com" onMouseOver="window.status='Click here to visit our web site?';return(true)">The Sprezzatura Group</A>] [<I>World Leaders in all things RevSoft</I>] [<img src="http://www.sprezzatura.com/zz.gif">] [<script language="javascript">function openNewPage () {window.location.href=(document.TOCNavigator.pageToGoTo.options[document.TOCNavigator.pageToGoTo.selectedIndex].value);document.TOCNavigator.pageToGoTo.selectedIndex="0";}end hiding from non-JS browsers –></script>]
[<FORM ACTION "" METHOD=GET NAME="TOCNavigator"
<SELECT NAME="pageToGoTo" SIZE=1 onChange="openNewPage()">
<OPTION>Pull down this menu to choose whereabouts on the Sprezz site to go
<OPTION VALUE="http://www.sprezzatura.com">Home Page
<OPTION VALUE="http://www.sprezzatura.com/whatsnew.htm">What's New
<OPTION VALUE="http://www.sprezzatura.com/senl.htm">SENL
<OPTION VALUE="http://www.sprezzatura.com/patches.htm">Download S/LIST
<OPTION VALUE="mailto:[email protected]">Send mail to support at Sprezzatura
<OPTION VALUE="mailto:[email protected]">Send mail to sales at Sprezzatura
</SELECT>
</FORM>][/notag]
Mr Group,
The only problem is it changes the date and timestamp on the file.
Not nice, but could have been worse. I'll reconsider for my own file copying needs.
- Oystein -
… This is a function I wrote ages ago: …
I, the Group?
[notag]No,
I, Borg …
[<b>Resistance is futile!!</b>]
[<A HREF="http://www.sprezzatura.com" onMouseOver="window.status='Click here for assimilation';return(true)">The Sprezzatura Group</A>]
[<I>World Leaders in all things Star Trek</I>]
[<img src="http://www.sprezzatura.com/zz.gif">]
[<script language="javascript">function openNewPage () {window.location.href=(document.TOCNavigator.pageToGoTo.options[document.TOCNavigator.pageToGoTo.selectedIndex].value);document.TOCNavigator.pageToGoTo.selectedIndex="0";}end hiding from non-JS browsers –></script>] [<FORM ACTION "" METHOD=GET NAME="TOCNavigator" <SELECT NAME="pageToGoTo" SIZE=1 onChange="openNewPage()"> <OPTION>Pull down this menu to choose whereabouts on the Sprezz site to go <OPTION VALUE="http://www.sprezzatura.com">Home Page <OPTION VALUE="http://www.sprezzatura.com/whatsnew.htm">What's New <OPTION VALUE="http://www.sprezzatura.com/senl.htm">SENL <OPTION VALUE="http://www.sprezzatura.com/patches.htm">Download S/LIST <OPTION VALUE="mailto:[email protected]">Send mail to support at Sprezzatura <OPTION VALUE="mailto:[email protected]">Send mail to sales at Sprezzatura </SELECT> </FORM>][/notag] </QUOTE> —- === At 10 FEB 2000 10:16AM The Sprezzatura Group wrote: === <QUOTE>From the OpenInsight 3.5 README.WRI file…. ·Provided a utility to copy OS files; syntax is Utility("COPYFILE", SrcFile, DestFile). (SYSOBJ/$UTILITY, SYSOBJ/$UTILITYCOPYFILE, OICOMMON.DLL) The Sprezzatura Group World leaders in all things ReadMes[/i]
Group,
Is the COPYFILE Utility better suited for Swedes and the Dos_Copy subroutine nearer the Norwegian mindset?
![]()
What I mean is - are there any particular advantages to chosing either the Dos_Copy subroutine or the COPYFILE Utility?
Let me guess: The COPYFILE Utility is in essence a black box that just returns 1 (true$) when the copying succeeded and 0 (false$) otherwise. If you try with a long file name (e.g "123456789.txt") it unceremoniously truncates the name ("12345678.txt") and trudges on. It cannot do wildcard copy.
Neither can the Dos_Copy subroutine, but it does more error checking and with the source available is extendable both when it comes to functionality and error checking.
Correct?
What about performance? Like when my app needs to copy thousands of image files, totalling a few hundred megs of data.
- Oystein -
Use the Utility function to copy files. Its performance is good, it uses the correct read/write flags during copying, and it does not change the date/time of the file. Besides, I wrote it .
Cameron Purdy
Revelation Software
Cameron,
Those are all good reasons to be sure. I've already started using it. Just a minor detail: If the copy fails, is there any way to check what went wrong?
- Oystein -
Thanks for the tip, (and an interesting discussion)
/Bertil
I believe you can use Get_Status.
Cameron Purdy
Revelation Software
Cameron.
Thought I did. With a source file that didn't exist.
Well, I'll try again, and if Get_Status doesn't work it's no big deal - at least for what I want to use the copyfile Utility for now.
- Oystein -
Sprezz UK,
If I ever visit you again I'll try to remember to bring a can of beer from the Borg Brewery.
- Oystein -