Dir Problems

new topic     » topic index » view thread      » older message » newer message

Hi all,

Two directory problems with exw:

1. If you try to run a euphoria/win program located in a directory whose
long filename (even even long pathname) has spaces, you get an error like this:

   Can't open C:\Euphoria\EarTest\dist\Source\Blog.exw

The actual filename of the program is this:

   C:\Euphoria\EarTest\dist\Source\Blog fog\test.exw

2. If you have a euphoria program bound to exw and the name of the
directory the program is in is too long (haven't got an exact figure, but
say over 50 characters long), you get this message:

---------------
Euphoria 2.1 Public Domain Edition for 32-bit Windows.
Copyright (c) Rapid Deployment Software 1999
Permission is freely granted to anyone to copy and
redistribute this Public Domain Edition of Euphoria.

file name to execute?
----------------

Cut the directory name down to normal size, and it starts working just fine.


On a possibly related note (and the reason I was messing around with such
obscure stuff), I discovered that if you are using MCISendString to (say)
play a wav file, it chokes and croaks in the most remarkable way if the
path to your wave file has a directory or filename with a space in it.

I discovered this because I was working on an install script for a Euphoria
program and by default it installs things in "c:\Program Files".  With that
space in the directory name, wave files that were playing quite beautifully
before, suddenly quit working altogether.

It turns out that MCI strings are space delimited and won't allow quotation
marks (!).  MCI strings commonly have a pathname as part of them, and we
all know that pathnames under Win95+ commonly have spaces in them. So how
do you deal with the problem?

The solution (the only reasonable one I can figure, anyway) is to send the
"shortpathname" as the MCI string, instead of sending the "longpathname".
Luckily there is a windows procedure to get the short pathname for you if
you have the long pathname.

Here is some code to get the short pathname. It might (?) be nice to have
something like this somewhere in Euphoria, or in include files. Maybe even
in machine.e or somewhere, as it seems closely related to current_dir and
other such functions.

You use the code below something like this:

    shortpath=GetShortPathName(longpath)

----------------------------------------------------------------
--OK, it's not beautiful, but it works (so far, anyway . . . )

constant  getShortPathName= link_c_func(kernel32, "GetShortPathNameA",
{C_POINTER, C_POINTER, C_INT}, C_INT)


global function GetShortPathName(sequence longpath)
  sequence shortpath
  integer result, len
  atom lp, sp

  len=200
  lp=allocate_string(longpath)


    shortpath=repeat(0,len)
    sp=allocate_string(shortpath)
    result=c_func(getShortPathName,
       {lp,  -- points to a null-terminated path string
        sp,  --points to a buffer to receive the null-terminated short form
of the path
        len}) -- specifies the size of the buffer pointed to by sp

    if result > len then --if len wasn't long enough, then result is
                         --now the correct length
         len = result
         free (sp)
         shortpath=repeat(0,len)
         sp=allocate_string(shortpath)

         result=c_func(getShortPathName,
                   {lp,
                    sp,
                    len})
    end if

    shortpath = peek ({sp, result})
    free (sp)
    len=result
    free (lp)

  if result > 0 then return shortpath
  else return longpath end if           --if result = 0 then we had an error

end function

----------------------------------------------------------------


++++++++++++++++++++ Brent Hugh / bhugh at cstp.umkc.edu ++++++++++++++++++++
++++++++ University of Missouri-Kansas City, Conservatory of Music +++++++
++ Sheet Music/Recordings: http://www.sunflower.org/~bhugh/pathetic.spm ++
+ Internet Piano Concert:  http://cctr.umkc.edu/userx/bhugh/recital.html +
++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu