March 01, 2021, 10:40:29 PM

Author Topic: [bmx] CopyFile by Perturbatio [ 1+ years ago ]  (Read 538 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] CopyFile by Perturbatio [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : CopyFile
Author : Perturbatio
Posted : 1+ years ago

Description : Copies a source file to the destination

Code :
Code: BlitzMax
  1. Function CopyFile:Int(SourceFile:String, DestinationFile:String, AutoReplace:Int=False, BufSize:Int=4096)
  2.        
  3.         If FileType(SourceFile) <> 1 Then Return False
  4.         If FileType(DestinationFile) = 1 And Not AutoReplace Then Return False
  5.        
  6.         Local SourceStream:TStream = OpenStream(SourceFile,True,False)
  7.         Local DestStream:TStream = OpenStream(DestinationFile,False,True)
  8.        
  9.         CopyStream(SourceStream, DestStream, BufSize)
  10.         CloseStream(SourceStream)
  11.         CloseStream(DestStream)
  12.        
  13.         Return True
  14. End Function


Comments :


Grey Alien(Posted 1+ years ago)

 Nice, it probably also works to copy read only CD-files to your computer and making them non-read only as you are not doing anything with the attributes.


Perturbatio(Posted 1+ years ago)

 I updated it slightly to take into account the BufSize parameter of CopyStream.


D4NM4N(Posted 1+ years ago)

 great!, and to think i was about 2 research writing my own :)just what i was after!thanks


tonyg(Posted 1+ years ago)

 Can't you use BlitzMax's CopyFile function which does the same thing? Make sure you're updated.


Perturbatio(Posted 1+ years ago)

 unless you need to do something specific that the BRL CopyFile doesn't do, I'd suggest using that instead (I wrote this before the BMax update).


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal