system() and copy in DOS
Hello Everyone!
I am currently working an application that is mainly for Linux, but I am
trying to make it cross platform. If the user starts the application
with the command option -g, the application will copy a template
configuration file from its home directory into the user's current
directory.
In Linux, this works fine. However, in Windows XP I'm having a bit of a
problem because the filename being copied is truncated to eight
characters. Apparently it is a problem with long filenames, which as I
recall Euphoria has had some issues with in the past. I don't think
that it is Euphoria though, because of the fact that Euphoria isn't
actually doing the copying, it is simply calling the DOS copy command
via a call to system().
Here is the relevant code, which further description below.
-- start code
function copyTemplate(sequence name)
integer ok, loc
sequence bkname
if giOperatingSystem = LINUX then
system("cp -f --backup " & sWhereAmI & "Eudoxy.tpl " & name, 2)
ok = sequence(dir(name))
else
if sequence(dir(name)) then
bkname = reverse(name)
loc = find('.', bkname)
if loc != 0 then
bkname = reverse(bkname[loc .. length(bkname)]) & "bak"
else
bkname = reverse(bkname) & ".bak"
end if
if sequence(dir(bkname)) then
system("del " & bkname, 2)
end if
system("copy " & name & " " & bkname, 2)
system("del " & name, 2)
end if
-- Here's where things get all ate up.
system("copy " & sWhereAmI & "Eudoxy.tpl " & name, 2)
ok = sequence(dir(name))
end if
if ok then
puts(1, "\n\n" &
"A template configuration file named " & name & " has been\n"
&
"created for you in the directory from which you called\n" &
"eudoxy.\n\n" &
"To customize eudoxy's settings, just edit that file. For\n" &
"more information, see the notes in the template file, or\n" &
"eudoxy's documentation.\n\n" &
"Bye!\n")
return 1
else
puts(1, "eudoxy: error: unable to create " & name & "\n\n")
return 0
end if
end function
-- end code
Okay, looking at the ex.err file, I confirmed that the following
variables have the following values:
sWhereAmI = "c:\\maple4\\eudoxy\\src"
name = "Eudoxyfile"
bkname = "Eudoxyfile.bak"
Now, based upon these values, the command that system() should be
issuing is:
copy c:\maple4\eudoxy\src\Eudoxy.tpl Eudoxyfile
The file that I'm getting when this is executed via system() is EUDOXYFI
I've typed in the above command manually at the DOS prompt, and it works
fine, resulting in the file EUDOXYFILE. I can't quite understand what
is going on here, because it seems that copy is displaying two different
behaviors based upon whether or not it is being called from Euphoria.
This might be a real simple thing I'm just not getting. If anyone could
shed some light on this, I'd appreciate it.
Thanks!
Travis Beaty
Osage, Iowa.
P.S. As a side note, the DOS command window in XP is flaky as hell.
|
Not Categorized, Please Help
|
|