Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə253/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   249   250   251   252   253   254   255   256   ...   294
DelphiLanguageGuide

File Types
The following discussion of file types applies to the Win32 platform only. On the .NET platform, text files are
implemented with a class (as opposed to a record). Binary file types (e.g. 
File of MyType
) are not supported on
the .NET platform.
On the Win32 platform, file types are represented as records. Typed files and untyped files occupy 332 bytes, which
are laid out as follows:
type
TFileRec = packed record
  Handle: Integer;
  Mode: word;
  Flags: word;
    case Byte of
         0: (RecSize: Cardinal);
         1: (BufSize: Cardinal;
               BufPos: Cardinal;
               BufEnd: Cardinal;
               BufPtr: PChar;
               OpenFunc: Pointer;
               InOutFunc: Pointer;
               FlushFunc: Pointer;
               CloseFunc: Pointer;
               UserData: array[1..32] of Byte;
212


               Name: array[0..259] of Char; );
end;
Text files occupy 460 bytes, which are laid out as follows:
type
        TTextBuf = array[0..127] of Char;
        TTextRec = packed record
                Handle: Integer;
                Mode: word;
                Flags: word;
                BufSize: Cardinal;
                BufPos: Cardinal;
                BufEnd: Cardinal;
                BufPtr: PChar;        
                OpenFunc: Pointer;
                InOutFunc: Pointer;
                FlushFunc: Pointer;
                CloseFunc: Pointer;
                UserData: array[1..32] of Byte;
                Name: array[0..259] of Char;
                Buffer: TTextBuf;
end;
Handle contains the file's handle (when the file is open).
The 
Mode
 field can assume one of the values
const
    fmClosed = $D7B0;
    fmInput= $D7B1;
    fmOutput = $D7B2;
    fmInOut= $D7B3;
where fmClosed indicates that the file is closed, fmInput and fmOutput indicate a text file that has been reset
(fmInput) or rewritten (fmOutput), fmInOut indicates a typed or untyped file that has been reset or rewritten. Any
other value indicates that the file variable is not assigned (and hence not initialized).
The UserData field is available for user-written routines to store data in.
Name contains the file name, which is a sequence of characters terminated by a null character (#0).
For typed files and untyped files, RecSize contains the record length in bytes, and the Private field is unused but
reserved.
For text files, BufPtr is a pointer to a buffer of BufSize bytes, BufPos is the index of the next character in the buffer
to read or write, and BufEnd is a count of valid characters in the buffer. OpenFuncInOutFuncFlushFunc, and
CloseFunc are pointers to the I/O routines that control the file; see Device functions. Flags determines the line break
style as follows:
bit 0 clear LF line breaks
bit 0 set
CRLF line breaks
All other Flags bits are reserved for future use.
213



Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   249   250   251   252   253   254   255   256   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin