Game Development Community

New Project Bug

by Gary "ChunkyKs" Briggs · in Torque Game Builder · 12/13/2006 (5:57 pm) · 0 replies

// copy a file from src to dest
 static bool CopyFile(const char* src, const char* dest)
 {
    <snipped a bunch of stuff that copies a file by opening both and schlepping the contents from one into the other>
 }

bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
{
 	return CopyFile(fromName,toName);
}

Well, right.

First off, permissions aren't preserved in the CopyFile function on unix. Fixing this is an exercise for the inquisitive reader. Given the general nature of how-TGB-does-stuff, you can just go ahead and pretend this bug doesn't exist.

Next up, you can't just open a dir and schlep it into another and expect something useful to happen. As such, and since I'm too lazy to write my own recursive copy funtion (why reinvent the wheel anyways?), replace the function thus:

bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
{
 	// return CopyFile(fromName,toName);
	char cmd[1024];
	dSprintf(cmd, 1024, "cp -r%s \"%s\" \"%s\"", nooverwrite?"":"f", fromName, toName);
	return system(cmd);
}

So that fixes that one. Next up will be the fact that copying the contents of the Fish skeleton project doesn't work because the fish skeleton project is incomplete, at least on my system.

Gary (-;