Re: walk_dir() and full path

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

Julio C. Galaret Viera wrote:
> > > Is there a way to retrieve the full path for a file name supplied by
> > > walk_dir()?

> 
> Starting from a directory, c:\my_root_path\, I am trying to walk down a very
> deep directory tree, reading any files under sub-directories, modifying these
> files, and writing them again with the same tree-path but under different root
> directory: instead of c:\my_root_path\the-directory-walked-throuh I want to
> write them to
> c:\another_root_path\the-same-sub-directory-that-was-walked-through.
> 
> The problem is that walk_dir() does not supply information about
> sub-directories
> it is walking through.

What does this example program show you? Is it what you wanted?

include file.e

function action(sequence pPath, sequence pDir)

    sequence lToDir
    integer lPos

    if find('d', pDir[D_ATTRIBUTES]) = 0 then
        lPos = find('\\', pPath[4..$])
        if lPos then
            lPos += 4
        else
            lPos = length(pPath)
        end if
        lToDir = pPath[1..3] & "NEWLOC\\" & pPath[lPos..$]
        printf(1, "Copying %s\\%s to %s\\%s\n",
                        {pPath, pDir[D_NAME], lToDir, pDir[D_NAME]})
    end if

    return 0
end function

object VOID

VOID = walk_dir("C:\\EUPHORIA", routine_id("action"), 1)


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu