home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1987 / 10 / dosfunc / dirmtdta.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-08-04  |  2.5 KB  |  54 lines

  1. (* ----------------------------------------------------------------------- *)
  2. (*                           DIRMTDTA.PAS                                  *)
  3. (*              (c) 1987  Michael Ceol & PASCAL INT.                       *)
  4. (* Eintrag aus DTA (MS-DOS und TOS) in das Format der Bibliothek bringen:  *)
  5. PROCEDURE DTAtoDirEntry (VAR entry: Dir_Rec);
  6. VAR i: INTEGER;  temp: Dir_Str;
  7. BEGIN
  8.  WITH entry DO
  9.   IF DirResult = DOSfnok THEN BEGIN
  10.         (* Dateiname: CHAR-Array nach String, 0-Byte kennzeichnet das Ende *)
  11.     temp := '';  i := 1;
  12.     WHILE (i <= 13) AND (DirDTA^.name[i] <> Chr(0)) DO BEGIN
  13.       temp := Concat(temp, DirDTA^.name[i]); i := Succ(i);
  14.     END;
  15.                        (* wg. Sortierung Name und Art (Extension) trennen: *)
  16.     i := Pos('.',temp);  ext := '';
  17.     IF i > 1 THEN ext := Copy(temp,Succ(i),Length(temp)-i)   (* Ext. vorh. *)
  18.     ELSE i := Succ(Length(temp));    (* keine Ext. oder 'Mama'-Verzeichnis *)
  19.     name := Copy(temp,1,Pred(i));
  20.                     (* wiederum wg. Sortierung mit Leerzeichen auffuellen: *)
  21.     FOR i := Succ(Length(name)) TO 8 DO name := Concat(name,' ');
  22.     FOR i := Succ(Length(ext)) TO 3 DO ext := Concat(ext,' ');
  23.  
  24.       (* MS-DOS- und TOS-Format von Datum und Zeit:
  25.            Datum - Bits: 0..4: Tag,  5..8: Monat,    9..15: Jahr-1980
  26.            Zeit  - Bits: 0..4: Sek. im 2-Sekunden-Intervall,
  27.                                     5..10: Minuten, 11..15: Stunden        *)
  28.  
  29.       (* Uhrzeit der Dateierstellung nach Zeichenfolge (Std., Min., Sec.): *)
  30.     IntStr(ShiftR(DirDTA^.time, 11), 2, temp);
  31.     time := temp;
  32.     IntStr(AndInt(ShiftR(DirDTA^.time, 5),63), 2, temp);
  33.     time := Concat(time, temp);
  34.     IntStr(AndInt(DirDTA^.time, 31)*2, 2, temp);
  35.     time := Concat(time, temp);
  36.         (* Datum der Dateierstellung nach Zeichenfolge (Jahr, Monat, Tag): *)
  37.     IntStr(ShiftR(DirDTA^.date, 9) + 1980, 4, temp);
  38.     date := temp;
  39.     IntStr(AndInt(ShiftR(DirDTA^.date, 5), 15), 2, temp);
  40.     date := Concat(date, temp);
  41.     IntStr(AndInt(DirDTA^.date, 31), 2, temp);
  42.     date := Concat(date, temp);
  43.                                (* schliesslich Dateigroesse und -Attribut: *)
  44.     size := IntCard(DirDTA^.szhi) * 65536.0 + IntCard(DirDTA^.szlo);
  45.     attr := DirDTA^.resv[21];
  46.    END
  47.   ELSE
  48.    BEGIN
  49.     name := '';  ext := '';  date := '';  time := '';  size := 0.0;
  50.    END;
  51. END;
  52. (* ----------------------------------------------------------------------- *)
  53. (*                           DIRMTDTA.PAS                                  *)
  54.