Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Manipulating files in subdirectories
Pages: [1] Print
Author Topic: Manipulating files in subdirectories  (Read 700 times)
Stoop
Newbie
*
Offline Offline

Posts: 10


View Profile
Manipulating files in subdirectories
« on: November 09, 2004, 09:46:37 AM »

I have a subdirectory off my REBOL directory called serverlogs.

I want to be able to get at these log files, but don't want to have to use change-dir system/options/path/serverlogs

So, what does work is that when I do a:

foreach file read %serverlogs/ [print file]

Sure enough I get a print out of the filenames, but if I try and do something else in my program like read in the lines of the files with something like:

foreach file read %serverlogs [lines: read/lines file]

I get the following error
** Access Error: Cannot open /C/rebol/serverlogs
** Near: foreach file read %serverlogs [lines: read/lines file]

Doesn't the lines: assignment know that the files are in a subdirectory?

How do I change this so it works - all the examples I see online use change-dir, and I don't wan to do that.

Thanks.

 
Logged
CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
Manipulating files in subdirectories
« Reply #1 on: November 10, 2004, 12:27:57 AM »

Reading a directory creates a block containing the file-names and directory-names in the directory, but not their full paths.  The solution to your problem is to join the path to the file-name.  ie...

... [lines: read/lines join %/C/rebol/serverlogs/ file]

If needs be, you can get the path to the current directory using WHAT-DIR.  So alternatives to the above could be...

... [lines: read/lines rejoin [what-dir %serverlogs/ file]]

or ...

path: join what-dir %serverlogs/
...
... [lines: read/lines join path file]
 
Logged

- Carl Read
Stoop
Newbie
*
Offline Offline

Posts: 10


View Profile
Manipulating files in subdirectories
« Reply #2 on: November 10, 2004, 01:37:53 PM »

OK, so the block doesn't hold full-path information.

Thanks very much for clarifying that and for the examples - most appreciated.

Stuart
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Manipulating files in subdirectories
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 29, 2008, 02:07:17 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2234 Posts in 582 Topics by 1745 Members
Latest Member: vectlycle

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc