2023年11月15日 星期三

delphi file record delphi data storage data file delphi data storage in recfile record

 browser local db storage

10 client-side storage options and when to use them

https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Structured_Types_(Delphi)

delphi recfile Seek(recFile,FileSize(recFile));. recPos := FilePos( recFile );. FilePosLabel.Caption := IntToStr( recPos );. FILESIZE IN DELPHI AND LAZARUS. There are two ... https://docwiki.embarcadero.com/radstudio/alexandria/en/internal_data_formats_(delphi)
https://docwiki.embarcadero.com/radstudio/alexandria/en/approaches_to_file_i/o
https://github.com/shusaura85/TDataFile
https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Internal_Data_Formats_(Delphi)
Database: Optimal Approaches for Data Storage in Delphi
https://copyprogramming.com/howto/which-is-the-best-method-to-save-data-in-delphi
delphi data storage data file

 version of the compiler.
File Types

File types are represented as records. Typed files and untyped files occupy 592 bytes on 32-bit platforms and 616 bytes on 64-bit platforms, which are laid out as follows:

 type
   TFileRec = packed record
     Handle: NativeInt;
     Mode: word;
     Flags: word;
     case Byte of
       0: (RecSize: Cardinal);
       1: (BufSize: Cardinal;
           BufPos: Cardinal;
           BufEnd: Cardinal;
           BufPtr: _PAnsiChr;
           OpenFunc: Pointer;
           InOutFunc: Pointer;
           FlushFunc: Pointer;
           CloseFunc: Pointer;
           UserData: array[1..32] of Byte;
           Name: array[0..259] of WideChar; );
  end;

Text files occupy 730 bytes on Win 32 and 754 bytes on Win64, which are laid out as follows:

 type
   TTextBuf = array[0..127] of Char;
   TTextRec = packed record
     Handle: NativeInt;
     Mode: word;
     Flags: word;
     BufSize: Cardinal;
     BufPos: Cardinal;
     BufEnd: Cardinal;
     BufPtr: _PAnsiChr;
     OpenFunc: Pointer;
     InOutFunc: Pointer;
     FlushFunc: Pointer;
     CloseFunc: Pointer;
     UserData: array[1..32] of Byte;
     Name: array[0..259] of WideChar;
     Buffer: TTextBuf; //
     CodePage: Word;
     MBCSLength: ShortInt;
     MBCSBufPos: Byte;
     case Integer of
       0: (MBCSBuffer: array[0..5] of _AnsiChr);
       1: (UTF16Buffer: array[0..2] of WideChar);
   end;


http://mc-computing.com/languages/delphi/delphifileio.htm

File I/O Commands
Open File for I/O     FileOpen(const FileName: string; Mode: Integer): Integer;
AssignFile(F, OpenDialog1.FileName);
Rewrite(var F: File [; Recsize: Word ] );
Append(var F: Text);
Get File Mode     F.Mode or (F as TFileRec).Mode
Write to File     FileWrite(Handle: Integer; const Buffer; Count: Integer): Integer;
Write to TextFile     Writeln, Write
Write to File     BlockWrite()
Read From TextFile     Read, Readln
Read From File     BlockRead()
Set Current Location    Seek(var F; N: Longint);
Get Current Location    FilePos(var F)
Length of File     FileSize(var F)
End of File     while not Eof(F1) do
Close File     FileClose(Handle: Integer)
CloseFile(F1);
Closes All Files     Not available in Delphi

https://www.tek-tips.com/viewthread.cfm?qid=1527339
File IO - Embarcadero: Delphi - Tek-Tips
procedure TForm1.InsertBlockNumbersClick(Sender: TObject);
Var
    infile, outfile: TextFile;
    inBuffer,outBuffer: array[1..65536] of char;
begin
    AssignFile(Infile, FullFileName);
    reset(infile);
    System.SetTextBuf(infile, inBuffer);
    System.SetTextBuf(outfile, outBuffer);
    AssignFile(outfile, FullFileName);
    rewrite(outfile);

    writeln(outfile, '(Tests InsertBlockNumbers.)');
        while not eof(infile) do
            begin
              //Do Something
            end;
    CloseFile(infile);
    CloseFile(outfile);
end;

http://delphibasics.50webs.com/NameSpace/Name/System.IO/Part/FileAccess.html
 System.IO
    
  BinaryReader      Class
  BinaryWriter      Class
  BufferedStream      Class
  Directory      Class
  DirectoryInfo      Class
  File      Class
  FileAccess      Enumeration
  FileAttributes      Enumeration
  FileInfo      Class
  FileMode      Enumeration
  FileShare      Enumeration
  FileStream      Class
  FileSystemWatcher      Class
  MemoryStream      Class
  Path      Class
  SeekOrigin      Enumeration
  StreamReader      Class
  StreamWriter      Class
  StringReader      Class
  StringWriter      Class

var
  LogFile: string = 'c:\log.txt';

// Append a message to a log file. See the example with the Array
// Keyword for the other overloaded Log procedure.
procedure Log(const Msg: string); overload;
var
  F: TextFile;
begin
  AssignFile(F, LogFile);
  // Try to append to the file, which succeeds only if the file exists.
{$IoChecks Off}
  Append(F);
{$IoChecks On}
  if IOResult <> 0 then
    // The file does not exist, so create it.
    Rewrite(F);
  WriteLn(F, Msg);
  CloseFile(F);
end;

https://www.drbob42.com/books/htmldata.htm

delphi embarcadero file class
https://blogs.embarcadero.com/loading-bitmaps-and-cursors-from-res-files/
https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Using_Streams_to_Read_or_Write_Data
https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Using_File_Streams
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TFileStream.Create
https://docwiki.embarcadero.com/CodeExamples/Sydney/en/ReadWriteFile_(Delphi)

delphi File Of Record_Type

https://github.com/graphics32/graphics32/blob/744df8aa07251e3457553abd3f039d2352d37aa8/Source/GR32.ImageFormats.TBitmap.pas

delphi bitmap header record "file of"
 bitmap header fpc
https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tbitmap.html
https://github.com/edivando-fpc/BGRABitmap/blob/master/bgragraphics.pas

沒有留言: