On Thursday 06 September 2001 06:03 pm, Joseph McDonald wrote:

> Does this look like a good way to do it (assuming that each file has
> a number as a name starting at 1 and incrementing for each new file):
>
> def make_filename(file_num)
>     first_level = file_num%256
>     second_level = (file_num%65536)/256
>     filename = [first_level, second_level, file_num].join("/")
> end

Well, you'll probably have to make sure that the parent directories exist 
first, unless you want to just catch Errno::ENOENT exceptions and restart. 
You can't go making a file in a directory that doesn't exist yet.

And your code assumes that the path separator is a slash (this is not true, 
for instance, on the Mac). You may want to use File::SEPARATOR instead.

It also assumes that there is such a thing as a current directory and/or 
relative filenames (this is not true on Windows/CE). You may want to allow 
for a path prefix to the filename.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned / bike-nomad.com
homepage:  http://bike-nomad.com