Re: dos.e

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

I, for one, use DOS for several tasks, Windows for many others, and Dragon
Linux for a few ones.
----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: dos.e


>
> Good work, J. Maybe not many people use DOS anymore blink
>
> ----- Original Message -----
> From: <jluethje at gmx.de>
> To: "EUforum" <EUforum at topica.com>
> Sent: Sunday, May 19, 2002 8:11 AM
> Subject: dos.e
>
>
> >
> > Hi all,
> >
> > there are some bugs in dos.e (from Archive/Library Routines)
> > -- tested with Euphoria 2.3:
> >
> >
> > =============================[ deltree() ]==============================
> >
> > <code>
> > global function deltree(string dirname)
> >    [...]
> >    if not compare(dirname[length(dirname)], "\\") then
> >       dirname = dirname[1..length(dirname)-1]
> >    end if
> > </code>
> >
> > The condition   compare(dirname[length(dirname)], "\\")
> > is *always* -1, because dirname[length(dirname)] is an atom, and
> > "\\" is a sequence.
> >
> > So the statement   dirname = dirname[1..length(dirname)-1]   will
> > *never* be executed, and therefore the function will not work properly,
> > when called with a dirname that has a backslash at the end.
> >
> > ==> It should be:  if not compare(dirname[length(dirname)], '\\') then
> >     or (clearer):  if dirname[length(dirname)] = '\\' then
> >
> > ----------------------------------------
> >
> > Also in function deltree:
> >
> > <code>
> >    info = dir(dirname)
> >    [...]
> >    if not match(info[loop][D_ATTRIBUTES],"d") then
> >       i = delete(dirname & "\\" & info[loop][D_NAME])
> > </code>
> >
> > For a normal file, info[loop][D_ATTRIBUTES] is "", and then the error
> > "first argument of match() must be a non-empty sequence" is raised.
> > (BTW: I think this information should be included in the documentation
> >       for match().)
> >
> > Furthermore, eg match("da", "d") = 0, which means that the routine will
> > try to delete() a directory with the attributes "da", for instance
> > (which will not work, of cause).
> >
> > ==> It should be:  if not find('d', info[loop][D_ATTRIBUTES]) then
> >
> > ----------------------------------------
> > This is my modified deltree() function:
> > ----------------------------------------
> >
> > global function deltree (string dirname)
> >    object info
> >    integer i
> >
> >    if dirname[length(dirname)] = '\\' then
> >       dirname = dirname[1..length(dirname)-1]
> >    end if
> >    info = dir(dirname)
> >    if atom(info) then
> >       return false
> >    end if
> >    if length(info) < 3 then
> >       return rmdir(dirname)
> >    end if
> >    info = info[3..length(info)]
> >    for loop = 1 to length(info) do
> >       if not find('d', info[loop][D_ATTRIBUTES]) then
> >          i = delete(dirname & "\\" & info[loop][D_NAME])
> >          if not i then
> >             return false
> >          end if
> >       else
> >          i = deltree(dirname & "\\" & info[loop][D_NAME])
> >          if not i then
> >             return false
> >          end if
> >          i = rmdir(dirname & "\\" & info[loop][D_NAME])
> >       end if
> >    end for
> >    return rmdir(dirname)
> > end function
> >
> >
> > ==============================[ rename() ]==============================
> >
> > <code>
> > global function rename(string oldname, string newname)
<snip>

>
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu