1. walk_dir() and full path

Is there a way to retrieve the full path for a file name supplied by walk_dir()?

JG

new topic     » topic index » view message » categorize

2. Re: walk_dir() and full path

> Is there a way to retrieve the full path for a file name supplied by
> walk_dir()?

Your function provides 2 parameters: 'path' and 'entry'. 'path' is the
current path, 'entry' is a dir entry (ths I'm sure you already know,
just establishing the facts). Take the D_NAME part of entry and append
it to path, you should have the full path.

function your_func( sequence path, sequence entry )

    sequence full_path

    full_path = path &'\\' & entry[D_NAME]

    return 0  -- keep going
end function


~Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: walk_dir() and full path

Greg Haberek wrote:
> 
> > Is there a way to retrieve the full path for a file name supplied by
> > walk_dir()?
> 
> Your function provides 2 parameters: 'path' and 'entry'. 'path' is the
> current path, 'entry' is a dir entry (ths I'm sure you already know,
> just establishing the facts). Take the D_NAME part of entry and append
> it to path, you should have the full path.
> 
> }}}
<eucode>
> function your_func( sequence path, sequence entry )
> 
>     sequence full_path
> 
>     full_path = path &'\\' & entry[D_NAME]
> 
>     return 0  -- keep going
> end function
> </eucode>
{{{

> 
> ~Greg
> 
> 


I know the path but the program doesn't.

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.

JG

new topic     » goto parent     » topic index » view message » categorize

4. Re: walk_dir() and full path

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 message » categorize

5. Re: walk_dir() and full path

Yes, that is what I want to do. Thanks Derek and Greg.

JG

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu