Game Development Community

Help about Torque Script

by M Mahmud Hasan · in Torque Game Engine · 12/02/2006 (12:02 pm) · 2 replies

Hi,

I need some help about file manipulation using Torque Script. I don't know if it is possible or not.
I need to write a function that will copy one file from one folder to another.

Can anyone help me, how to do this? I checked out the TDN for script File I/O section, but I didn't get any help.

Thank you in advnce!!

#1
12/02/2006 (1:43 pm)
I honestly don't think I would do this in script. I'm a big fan of using FILE* for that kind of work, which is done in C++. But since you asked:

function copyFile(%sourceFilePath, %destinationFilePath)
{
      %souceFile = new FileObject();
      %destFile = newFileObject();

       %sourceFile.openForRead(%sourceFilePath);
       %destFile.openForWrite(%destinationFilePath);

      while(!%sourceFile.isEOF())
      {
             %line = %sourceFile.readLine();
             %destFile.writeLine(%line);
      }

     %sourceFile.delete();
     %destFile.delete();
}

I haven't tried it yet, but that's my understanding of Torque Script file I/O. Here's the TDN link: FileObject
#2
12/04/2006 (10:52 am)
Thanks a lot Perry. I think I'll give it a shot!!