Re: Equal Distribution
- Posted by David Cuny <dcuny at LANSET.COM> Mar 19, 2001
- 501 views
CK Lester wrote: > Can anybody drop me a clue as to how I > would best equally distribute those files? You could write the files as a 'single' file, spread across several disks. For example (untested code): -- list of files constant files = { "this", "that", "other" } -- constants disk = 1 -- current disk number at = 0 -- offset into disk disksize = 100 -- bytes per disk -- the 'fat' table fat = open( "fat", "w" ) -- write the files handle = open( sprintf( "disk%d", {disk} ), "w" ) for i = 1 to length( files ) do -- read the file data = read_file( file[i] ) -- write to fat file printf( fat, "%d, %d, %d, %d", {file[i], disk, at, length(data)} ) -- write the data for i = 1 to length( data ) do putc( handle, data[i] ) -- move ahead at += 1 -- spans disk? if at > disksize then -- close old file close( handle ) -- increment disk number disk += 1 -- open new disk file handle = open( sprintf( "disk%d.dat", {disk} ), "w" ) end if end for end for close( handle ) close( fat ) Reversing this (reading the file layouts from the fat table) allows the files to be reconstructed from the data files. -- David Cuny