There are two things you need to worry about:
1) Insuring that the pathnames to the files that you're copying are formatted properly for the shell if on NT (/'s need to be turned into 's).
2) That you call the proper copy command, depending on the type of machine that you're on ("cp" on UNIX, "copy" on NT).
Here's a couple of handy MEL functions that will make this simpler - BMT_sysCopy() provides a copy function that will work on both UNIX and NT architectures - it automatically detects which OS you're running on, and uses the proper command.
The other two functions are required for BMT_sysCopy() to work:
BMT_fileNTify() - transltes / to in filenames
BMT_joinStringArray() - used by BMT_fileNTify()
You can use the copy function with something like:
$from_file = "c:/some/location/of/some/file";
$to_file = "c:/destination/location/of/ile";
BMT_sysCopy($from_file, $to_file);
(BMT_sysCopy() will automatically call NTify on the filenames for you, so it's not necessary to modify them ahead of time.
If this kind of stuff is useful, let me know, and I can upload some more complete libraries for this type of stuff that I've written for use on my own productions.
=====================================
MEL FUNCTIONS:
=====================================
//---------------------------------------------------------------------------
// BMT_sysCopy($from, $to)
//
// Copy a file:
//---------------------------------------------------------------------------
global proc BMT_sysCopy(string $from, string $to)
{
string $os = about -os
;
switch ($os)
{
case "linux":
case "irix":
$cmd = "cp ";
break;
case "nt":
$cmd = "copy ";
break;
default:
error("Unknown operating system type: "+$os);
}
$cmd += BMT\_fileNTify($from) + " " + BMT\_fileNTify($to);
if (getenv("BMT\_DEBUG") == "1")
print("==System call: "+$cmd+"n");
system($cmd);
}
//---------------------------------------------------------------------------
// BMT_fileNTify($filename)
//
// replaces '/' characters in a filename with '' characters for use
// in NT systems where we need that format - only does this substitution
// if the current operating system is NT, otherwise returns the string
// unmodified:
//---------------------------------------------------------------------------
global proc string BMT_fileNTify(string $filename)
{
if (about -os
== "nt")
{
string $parts[];
tokenize($filename, "/", $parts);
$filename = BMT_joinStringArray("", $parts);
}
return $filename;
}
//---------------------------------------------------------------------------
// BMT_joinStringArray($join_string, $array[])
//
// Similar to PERL join() function, returns a string with all of the items
// in the array concatenated with $join_string between them
//---------------------------------------------------------------------------
global proc string BMT_joinStringArray(string $join_string, string $array[])
{
int $i;
string $join = $array[0];
for ($i=1; $i < size($array); $i++)
$join += $join\_string + $array[$i];
return $join;
}
--Coop