1. system() and copy in DOS
- Posted by Travis Beaty <tbeaty at osage.net> Jul 29, 2003
- 414 views
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.
2. Re: system() and copy in DOS
- Posted by Robert Craig <rds at RapidEuphoria.com> Jul 30, 2003
- 411 views
Travis Beaty wrote: > 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(). When you run the system() command in ex.exe, XP runs an old version of DOS that only supports 8.3 filenames. If you run system() using exw.exe (or exwc.exe - see euphoria\bin\makecon.exw) you'll get full support for long filenames. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: system() and copy in DOS
- Posted by Juergen Luethje <j.lue at gmx.de> Jul 30, 2003
- 428 views
Hello all, Rob wrote: > Travis Beaty wrote: >> 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(). > > When you run the system() command in ex.exe, > XP runs an old version of DOS that > only supports 8.3 filenames. In that situation, *long* filenames can be processed by using my library "Lfn.zip" from the user contributions page. Instead of system("del " & bkname, 2) system("copy " & name & " " & bkname, 2) one has then to write system("del " & short_name(bkname), 2) system("copy " & short_name(name) & " " & short_name(bkname), 2) > If you run system() using exw.exe > (or exwc.exe - see euphoria\bin\makecon.exw) > you'll get full support for long filenames. Best regards, Juergen -- The difference between men and boys is the price of the toys.
4. Re: system() and copy in DOS
- Posted by Juergen Luethje <j.lue at gmx.de> Jul 30, 2003
- 411 views
Me wrote: > Rob wrote: > >> Travis Beaty wrote: >>> 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(). >> >> When you run the system() command in ex.exe, >> XP runs an old version of DOS that >> only supports 8.3 filenames. > > > In that situation, *long* filenames can be processed by using my library > "Lfn.zip" from the user contributions page. > Instead of > system("del " & bkname, 2) > system("copy " & name & " " & bkname, 2) > > one has then to write > system("del " & short_name(bkname), 2) > system("copy " & short_name(name) & " " & short_name(bkname), 2) ^^^^^^^^^^^^^^^^^^ Oops. If forgot to mention, that this may not lead to the desired result. 'short_name(file)' only works as expected, if 'file' already exists. To achieve this, don't delete it before copying. If the destination file does *not* already exist, just let your program first create a small destination file with the desired long 'bkname'. BTW: I personally prefer to let my program copy the data itself, using a small while() loop. I don't know, which method is faster. >> If you run system() using exw.exe >> (or exwc.exe - see euphoria\bin\makecon.exw) >> you'll get full support for long filenames. Best regards, Juergen -- The difference between men and boys is the price of the toys.
5. Re: system() and copy in DOS
- Posted by Travis Beaty <tbeaty at osage.net> Jul 30, 2003
- 420 views
Hello! Okay, thanks everyone. Juergen, I'll look into the library. I wanted to try to have all the include files be cross-platform, but it's now looking more like I'm going to have to make a separate include file which contains all the platform-specific code. I guess that's okay, just not how I originally planned. Thanks everyone! Travis Beaty Osage, Iowa. Juergen Luethje wrote: > > > Me wrote: > > >>Rob wrote: >> >> >>>Travis Beaty wrote: >>> >>>>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(). >>> >>>When you run the system() command in ex.exe, >>>XP runs an old version of DOS that >>>only supports 8.3 filenames. >> >> >>In that situation, *long* filenames can be processed by using my library >>"Lfn.zip" from the user contributions page. >>Instead of >> system("del " & bkname, 2) >> system("copy " & name & " " & bkname, 2) >> >>one has then to write >> system("del " & short_name(bkname), 2) >> system("copy " & short_name(name) & " " & short_name(bkname), 2) > > ^^^^^^^^^^^^^^^^^^ > Oops. If forgot to mention, that this may not lead to the desired > result. 'short_name(file)' only works as expected, if 'file' already > exists. To achieve this, don't delete it before copying. If the > destination file does *not* already exist, just let your program first > create a small destination file with the desired long 'bkname'. > > BTW: I personally prefer to let my program copy the data itself, using a > small while() loop. I don't know, which method is faster. > > >>>If you run system() using exw.exe >>>(or exwc.exe - see euphoria\bin\makecon.exw) >>>you'll get full support for long filenames. > > > Best regards, > Juergen >