[T2 Release] Copy File

Kaiten Commande
01-22-2003, 01:55 AM
ilys posed a question to me the other day when he was finishing off his scripts. "Can I copy files in T2?"

The only ways that I knew of was using a round about way in file_tools.cs or the save option in the Options Screen, but that would only save if the file was a MapFile.

I created this script to overcome this problem. What it does is reads the file line by line till it reaches EOF, then writes the lines back into the new file.

Used ingame to copy files. I don't know why people would want to copy files ingame except for backups before saving prefs, but you never know. Maybe can be used to backup prefs, cs files etc. This is resticted to plain text files (cs, txt, etc). This cannot be used to copy recordings, Screenshots, vl2 or dso files (binary).

Usage: CopyFile("PathTo/SourceFile", "PathTo/DestinationFile", optional true); <---- "PathTo" is relative to Base or mod directory.

Example: CopyFile("scripts/autoexec/copy.cs", "scripts/autoexec/copy.txt"); <--- Copies file if not existing

Example: CopyFile("scripts/autoexec/copy.cs", "scripts/autoexec/copy.txt", 1); <--- Overwrites file if existing

Errors:
"Error: Filenames may not contain any of the following characters: \\ ? * < > \' |" <-- Illegal Chars.
"Error: Source & Destination cannot be the same!" <---- Duh.
"Error: You cannot use blank filenames!" <---- Duh.
"Error: There is no file scripts/autoexec/copy.cs" <---- Source file doesn't exist.
"Error: scripts/autoexec/copy.txt allready exists. Please use a different filename." <---- File allready exists.

I am the first to admit that this file is fairly useless, but someone might find a use for it.

Download (http://www.kaiten.barrysworld.ne t/download.php?op=download&id=31&url=files/zSCRIPT-CopyFile.vl2)

LouCypher
01-22-2003, 03:01 AM
I said this in the GameShrine forums, but since I don't think UberGuy reads those, I think this would be an excellent inclusion to support.vl2. :)

Mr. Hated
01-23-2003, 07:48 AM
i could use that

UberGuy (FT)
01-23-2003, 09:02 AM
Actually I saw that, Lou, and tried to respond there, but no one has ever activated my account over there. I signed up and never got a mail.

Anyway, this seems like a decent thing to add. Kaiten, two questions: if I added it would you object to me adding it to something like file_tools.cs and would you object to me renaming the function to copyTextFile() ?

Kaiten Commande
01-23-2003, 10:30 AM
No problem Uber :)

ilys
01-23-2003, 09:16 PM
Originally posted by UberGuy (FT)
Actually I saw that, Lou, and tried to respond there, but no one has ever activated my account over there. I signed up and never got a mail.
PJ gets an account but not Uber? :o
I'm gonna raise hell over this :p