[REBOL] Re: Directory tools
From: brett:codeconscious at: 13-Apr-2001 12:47
> Thanks for posting file-tools.r! I have been writing bits of it for myself
> as I needed them, and was currently balking at writing the
> directory-related functions (esp copying).
You're most welcome. I noticed while writing this email that I had not
included the top most target-directory
in the copy-directory function. I've rectified this in the version on my
website found at
http://www.codeconscious.com/rebol/scripts/file-tools.r
Looking at the code I'm wondering if it could be made a little more
explicit. I'm also not sure now
if it is handling relative FTP addressing properly. So I'll have to have
another look at it.
If you have some ideas I'd welcome them.
> I needed to modify the way that external code is included to use my own
> scheme, no problem.
Is it a generic scheme? Maybe I should add as an option to the functions? :)
> I added a /verbose refinement to copy-directory. I want to see what my
> script does to make sure it behaves itself!
Another way is to use the /script refinement to see the code that is
produced.
> However, I'm getting the following error in mime-read. What is the purpose
> of adding /full at the end of what should already be the full file path?
Inside mime-types.r there is a function called import-location-with-mime
which given a file! or url! returns an object where the components of the
file! or url! are in seperate fields. The /full refinement refers to a
function in this object which puts all the pieces back together again to
give you the original file! or url! (hopefully).
>> o: probe import-location-with-mime
%/d/html/eq/source/book-cod/about.r
make object! [
path: %/d/html/eq/source/book-cod/
name: %about
extension: %.r
full: func [][rejoin [path name extension]]
mime-type: func [][
get-mime-for-ext extension
]
]
>> o/full
== %/d/html/eq/source/book-cod/about.r
> >> retval: copy-directory/files/verbose %/d/html/eq/source/book-cod/
> ftp://user:[password--members--home--net]/source/book-cod/
> Copy Dir FROM: /d/html/eq/source/book-cod/
> TO: ftp://user:[password--members--home--net]/source/book-cod/
> - Copy file: about.r
> ** Script Error: Invalid path value: full
> ** Where: mime-read
> ** Near: read source-as-object/full
source-as-object should have been an object! with a field-function (method)
called "full", but it appears not. Maybe my import-location-as-mime function
blew up in the face of your new scheme?
Brett.