Console function - copy file to file
by Mark Brown · in Torque Game Engine · 04/07/2007 (2:20 pm) · 3 replies
Let's start with I can code in C but not in C++.
I got this far:
Torque Lib files/Source Files/core
fileObject.h
class FileObject : public SimObject
public:
bool copy_filetofile(const char *fileName_from, const char *fileName_to ); // <-- Added
fileObject.cc
bool FileObject::copy_filetofile(const char *fileName_from, const char *fileName_to )
{
long flag;
char buffer_from[1024];
char buffer_to[1024];
Con::expandScriptFilename( buffer_from, sizeof( buffer_from ), fileName_from );
close();
Con::expandScriptFilename( buffer_to, sizeof( buffer_to ), fileName_to );
close();
// "bool true" is overwrite flag set to true
flag = copyfile ( buffer_from, buffer_to, bool true );
if ( flag )
return ( false );
return ( true );
}
What do I do now coach???
My goal is "copy_filetofile ( texture_14.jpg, texture_building.jpg );
This command is at start up and not during running game.
real code would be helpful.
I got this far:
Torque Lib files/Source Files/core
fileObject.h
class FileObject : public SimObject
public:
bool copy_filetofile(const char *fileName_from, const char *fileName_to ); // <-- Added
fileObject.cc
bool FileObject::copy_filetofile(const char *fileName_from, const char *fileName_to )
{
long flag;
char buffer_from[1024];
char buffer_to[1024];
Con::expandScriptFilename( buffer_from, sizeof( buffer_from ), fileName_from );
close();
Con::expandScriptFilename( buffer_to, sizeof( buffer_to ), fileName_to );
close();
// "bool true" is overwrite flag set to true
flag = copyfile ( buffer_from, buffer_to, bool true );
if ( flag )
return ( false );
return ( true );
}
What do I do now coach???
My goal is "copy_filetofile ( texture_14.jpg, texture_building.jpg );
This command is at start up and not during running game.
real code would be helpful.
About the author
#2
Many thanks for saved hours!
//####################
//#
//#
// ConsoleFunction(pathCopy, bool, 3, 4, "pathCopy(fromFile, toFile [, nooverwrite = true])")
//#
//#
//####################
function set_random_textures ( )
{
%ja = random_int ( 5 );
switch ( %ja )
{
case 1:
%from_file = "./data/structures/rooms/roof_floor_color_01.jpg";
case 2:
%from_file = "./data/structures/rooms/roof_floor_color_02.jpg";
case 3:
%from_file = "./data/structures/rooms/roof_floor_color_03.jpg";
case 4:
%from_file = "./data/structures/rooms/roof_floor_color_04.jpg";
case 5:
%from_file = "./data/structures/rooms/roof_floor_color_05.jpg";
}
%nooverwrite = false;
%to_file = "./data/structures/rooms/roof_floor_color_00.jpg";
pathCopy ( %from_file, %to_file, %nooverwrite );
}
04/10/2007 (8:11 am)
This is just what I needed!!Many thanks for saved hours!
//####################
//#
//#
// ConsoleFunction(pathCopy, bool, 3, 4, "pathCopy(fromFile, toFile [, nooverwrite = true])")
//#
//#
//####################
function set_random_textures ( )
{
%ja = random_int ( 5 );
switch ( %ja )
{
case 1:
%from_file = "./data/structures/rooms/roof_floor_color_01.jpg";
case 2:
%from_file = "./data/structures/rooms/roof_floor_color_02.jpg";
case 3:
%from_file = "./data/structures/rooms/roof_floor_color_03.jpg";
case 4:
%from_file = "./data/structures/rooms/roof_floor_color_04.jpg";
case 5:
%from_file = "./data/structures/rooms/roof_floor_color_05.jpg";
}
%nooverwrite = false;
%to_file = "./data/structures/rooms/roof_floor_color_00.jpg";
pathCopy ( %from_file, %to_file, %nooverwrite );
}
#3
04/10/2007 (8:30 am)
Glad that got you what you needed
Community Manager Michael Perry
ZombieShortbus
More File Actions
You can do what you need from script. If you prefer doing so in the engine, just use the C++ calls already written. Why do extra work? =)