{*
 * @(#) writable.pas - Program for discovering all write-allowed subdirs.
 * (c) 1995 Ivan Maidanski <ivmai@chat.ru> http://ivmai.chat.ru
 * Freeware program source. All rights reserved.
 **
 * Language: Turbo Pascal
 * Tested with: Turbo Pascal v7.0
 * Last modified: 1995-04-12 21:20:00 GMT+04:00
 *}

program Writable;

{$I-,S+}
uses Dos;
function TestDir(Path: PathStr): Boolean;
 var F: File;
 begin
   Assign(F,Path+'WRITABLE.$$$');
   ReWrite(F);
   TestDir:=IOResult=0;
   Close(F);
   Erase(F)
 end;
procedure Scan(Path:PathStr);
 var DirInfo: SearchRec;
 begin
   if TestDir(Path)
     then WriteLn(Path);
   FindFirst(Path+'*.*',Directory,DirInfo);
   while DosError=0
     do begin
          if (DirInfo.Attr and Directory>0) and
             (DirInfo.Name<>'.') and (DirInfo.Name<>'..')
            then Scan(Path+DirInfo.Name+'\');
            FindNext(DirInfo)
        end;
   if DosError<>18
     then WriteLn('Dos Error')
 end;
begin
  if ParamCount=0
    then begin
           WriteLn('Shows all directories available for writing.');
           WriteLn('Usage: WRITABLE Path')
         end
    else Scan(FExpand(ParamStr(1)));
  WriteLn
end.
