My version, with deleting of the files when it gets full. You still need to hit cancel to 'Volume xxx is full' -requester.
/* filldrive.rexx */
options results
parse arg dir
if dir = '' then do
say 'Usage: rx filldrive.rexx <DIRECTORY>'
exit 0
end
if ~exists(dir) then do
say 'Directory' dir 'does not exist.'
exit 5
end
if ~show('l', 'rexxsupport.library') then do
if ~addlib('rexxsupport.library', 0, -30, 0) then do
say 'rexxsupport.library required'
exit 10
end
end
lc = right(dir, 1)
if (lc ~= ':' & lc ~= '/') then do
dir = dir || '/'
end
path = dir || '_fd_tempfile'
maxfill = 512 /* max fillsize in GB */
size = 2000000000
buffsize = 32768
buffer = left('', buffsize, '00'x)
say 'create fill files'
do i = 0 to maxfill/2
say 'create' path || i
if ~open('out', path || i, 'w') then leave
s = size
do while s >= buffsize
if writech('out', buffer) < buffsize then do
close(out)
leave i
end
s = s - buffsize
end
if s > 0 then do
if writech('out', left(buffer, s)) < s then do
close(out)
leave i
end
end
close('out')
end
say 'delete files'
do i = 0 to maxfill/2
delete(path || i)
end