[comp.lang.pascal] directory routines in Turbo pas

v105mahs@ubvmsc.cc.buffalo.edu (Peter P Donohue) (08/26/90)

   I have a few pascal questions that I am trying to get 
answered.  I use Turbo Pascal 5.5 running under MS-Dos 3.3. 
   How do you read the volume label of a disk?  I am working on 
a directory program but can't seem to figure out volume labels. 
   How can you read hidden files?  I'd like to get a count of 
the number of hidden files and sum up their sizes.  Any ideas? 
   Thanks in advance.

                                  Pete 

Peter P. Donohue - University at Buffalo, Graduate School of Management
bitnet:   V105MAHS@UBVMS                  .  "Education is a journy
internet: V105MAHS@UBVMS.CC.BUFFALO.EDU   .    not a destination..."

rio@image.me.utoronto.ca (Oscar del Rio) (08/27/90)

In article <33768@eerie.acsu.Buffalo.EDU> v105mahs@ubvmsc.cc.buffalo.edu writes:
>
>   I have a few pascal questions that I am trying to get 
>answered.  I use Turbo Pascal 5.5 running under MS-Dos 3.3. 
>   How do you read the volume label of a disk?  I am working on 
>a directory program but can't seem to figure out volume labels. 
>   How can you read hidden files?  I'd like to get a count of 
>the number of hidden files and sum up their sizes.  Any ideas? 

It is easy in TP 5.5. The following short program reads the volume label
of the current drive (looking in the root directory, where it is supposed
to be), and the files in the current directory, including the hidden ones. 

  uses Dos;
  var
    DirInfo: SearchRec;
  begin
    FindFirst('\*.*', VolumeID, DirInfo);
    WriteLn('Volume Label: ',DirInfo.Name);

    FindFirst('*.*', Hidden, DirInfo);
    WriteLn ('    Name        Size  Attr');
    while DosError = 0 do
      with DirInfo do
        begin
          Write(Name:12,Size:8,Attr:4);
          if (Attr and Hidden) = Hidden then
            write (' Hidden');
          writeln;
          FindNext(DirInfo);
        end;
  end.

I remember trying to do this in TP 3.0 some years ago. I didn't know much
about interrupts and I gave up!  Now Borland makes our programming easier.
:-)

-- 
Oscar Ivan del Rio                    | rio@tension.me.utoronto.ca
Department of Mechanical Engineering  | rio@me.toronto.edu
University of Toronto                 |
CANADA                                |