home *** CD-ROM | disk | FTP | other *** search
- {$R+}
- program pcdisk3;
-
- type
- filename = string[11];
- catalog_record = record
- volume_no : integer;
- file_name : filename;
- size1,size2 : integer;
- time,date : integer;
- description : string[33];
- end;
- index_record = record
- origin : integer;
- first_file : integer;
- last_file : integer;
- end;
-
- var
- datafilein : file of catalog_record;
- datafileout : file of catalog_record;
- cr : catalog_record;
- size : real;
- t1,t2,t3 : integer;
- d1,d2,d3 : integer;
- file_table : array[1..200] of catalog_record;
- file_count : integer;
- volume_table : array[1..20] of catalog_record;
- volume_index : array[0..20] of index_record;
- volume_count : integer;
- i, j : integer;
- keyid : integer;
- catfile,catfilex : string[80];
- line_count : integer;
- parm : string[80];
- pagesize : integer;
- view : boolean;
- outfile : text;
-
- function realsize(s1,s2 : integer) : real;
-
- var
- x : real;
-
- begin;
- if s1<0 then x := 65536.0+s1
- else x := s1;
- x := x+65536.0*s2;
- realsize := x;
- end; { conversion from two integers to a real }
-
- procedure sortvolume;
-
- var
- i, j, k : integer;
- lowkey : filename;
-
- begin
- for i := 1 to volume_count-1 do begin
- k := i;
- lowkey := volume_table[i].file_name;
- for j := i+1 to volume_count do begin
- if lowkey>volume_table[j].file_name then begin
- k := j;
- lowkey := volume_table[j].file_name;
- end; { saving new low key and index }
- end; { search for current lowest key and index }
- if k<>i then begin
- cr := volume_table[i];
- volume_table[i] := volume_table[k];
- volume_table[k] := cr;
- volume_index[0] := volume_index[i];
- volume_index[i] := volume_index[k];
- volume_index[k] := volume_index[0];
- end; { swap if current is not lowest }
- end; { sorting the volume table, slowly }
- end; { volume sort procedure }
-
- begin
- catfile := 'C:\PUBLIC\COLLECT.DAT';
- parm := ParamStr(1);
- if length(parm)>0 then catfile := parm;
- volume_count := 0;
- file_count := 0;
- assign(datafilein,catfile);
- {$i-}
- reset(datafilein);
- {$i+}
- if IOresult<>0 then begin
- writeln('Unable to open ',catfile,'. Program halted');
- halt;
- end;
- while(not eof(datafilein)) do begin
- read(datafilein,cr);
- if cr.volume_no=-1 then begin
- volume_count := volume_count+1;
- volume_table[volume_count] := cr;
- with volume_index[volume_count] do begin
- origin := volume_count;
- first_file := 0;
- last_file := 0;
- end;
- writeln(volume_count:2,' ',cr.file_name);
- end
- else begin
- file_count := file_count+1;
- file_table[file_count] := cr;
- if volume_index[volume_count].first_file=0 then
- volume_index[volume_count].first_file := file_count;
- volume_index[volume_count].last_file := file_count;
- end;
- end;
- writeln(file_count,' file records read.');
- writeln(volume_count,' volume records read.');
- close(datafilein);
- sortvolume;
- i := pos('.',catfile);
- writeln('Period location ',i);
- if i>0 then catfilex := copy(catfile,1,i-1)
- else catfilex := catfile;
- assign(datafileout,catfilex+'.111');
- {$I-} rewrite(datafileout); {$I+}
- if IOresult<>0 then begin
- {$I-} reset(datafileout); {$I+}
- if IOresult<>0 then begin
- writeln('Unable to open output temporary ',catfilex+'.111');
- halt;
- end;
- end;
- for i := 1 to volume_count do begin;
- write(i,' ',volume_table[i].file_name,' ');
- write(datafileout,volume_table[i]);
- with volume_index[i] do begin
- writeln(first_file:3,last_file:3);
- for j := first_file to last_file do begin
- file_table[j].volume_no := i;
- write(datafileout,file_table[j]);
- end;
- end;
- end;
- close(datafileout);
- rename(datafilein,catfilex+'.bak');
- rename(datafileout,catfile);
- end.
- end;
- close(datafileout);
- rename(datafilein,catfilex+'.bak');
- r