Streams Utilities
OpenFileStream
Opens a file stream with the specified access mode and creates a ThFileStream instance for the file.The function initializes the stream and returns whether the operation was successful.
function OpenFileStream(FileName: String; Access: ThFileStream_Access; var FS: ThFileStream): Boolean;
Parameters
- FileName: String; The name or path of the file to open.
- Access: ThFileStream_Access; The file access mode (such as read, write, or read/write).
- FS: var ThFileStream; Variable that will receive the created ThFileStream instance.
Return Value
Returns True if the file stream was opened and the instance created successfully.Returns False if the operation failed.
Create_Package_File
Creates a ZIP package file containing all files listed in the provided source files list.The resulting package is saved with the specified ZIP file name.
function Create_Package_File(ZipFileName, Source_Files_List: String): Boolean;
Parameters
- ZipFileName: String; The name or path for the new ZIP package file.
- Source_Files_List: String; A list of source files to include in the package, usually separated by semicolons or line breaks.
Return Value
Returns True if the package was created successfully.Returns False if the operation failed.
Get_Files_List
Retrieves a list of files contained in the specified ZIP package file.Returns the list as a string.
function Get_Files_List(ZipFileName: String): String;
Parameters
- ZipFileName: String; The name or path of the ZIP package file to read.
Return Value
Returns a string listing all files in the ZIP package.An empty string indicates the operation failed or the package contains no files.
Extract_File_Into_MS
Extracts a specific file from a ZIP package and writes its content into a memory stream.The operation does not save the file to disk, but loads it directly into the provided ThMemoryStream instance.
function Extract_File_Into_MS(FileName, ZipFileName: String; MS: ThMemoryStream): Boolean;
Parameters
- FileName: String; The name of the file to extract from the ZIP package.
- ZipFileName: String; The name or path of the ZIP package file.
- MS: ThMemoryStream; The memory stream that will receive the extracted file data.
Return Value
Returns True if the file was extracted into the memory stream successfully.Returns False if the operation failed.
Extract_All_Files
Extracts all files from a ZIP package into the specified target directory.Creates the necessary folders and writes each file from the package to disk.
function Extract_All_Files(ZipFileName, ExtractTo: String): Boolean;
Parameters
- ZipFileName: String; The name or path of the ZIP package file.
- ExtractTo: String; The directory where the files will be extracted.
Return Value
Returns True if all files were extracted successfully.Returns False if the operation failed.
Fast_File_CRC_Word
Calculates a CRC word checksum for the specified file using a fast algorithm.Useful for verifying file integrity.
function Fast_File_CRC_Word(FileName: String): Word;
Parameters
- FileName: String; The name or path of the file to process.
Return Value
Returns the computed CRC word value for the file.Decode_Quoted_Printable
Decodes data in quoted-printable encoding from the source memory stream and writes the result to the target memory stream.Processes the data within the specified range in the source stream.
function Decode_Quoted_Printable(Source: ThMemoryStream; FromPos, UntilPos: Cardinal; var Target: ThMemoryStream): Boolean;
Parameters
- Source: ThMemoryStream; The source memory stream containing quoted-printable data.
- FromPos: Cardinal; Starting position in the source stream.
- UntilPos: Cardinal; Ending position in the source stream.
- Target: var ThMemoryStream; The target memory stream to receive the decoded data.
Return Value
Returns True if decoding was successful.Returns False if the operation failed.
Write_Log_File_From_Stream
Writes the entire content of the specified stream to a log file.Optionally adds extra CRLF (Carriage Return and Line Feed) characters.
procedure Write_Log_File_From_Stream(Source: ThStream; ExtCRLF: Boolean = False);
Parameters
- Source: ThStream; The stream containing data to write to the log file.
- ExtCRLF: Boolean; If True, adds extra CRLF characters between lines (default is False).
Encode_BASE64_String
Encodes the input data as a BASE64 string.BASE64 encoding is used for safe transfer of binary data as text.
function Encode_BASE64_String(Input: RawByteString): RawByteString;
Parameters
- Input: RawByteString; The binary data to encode.
Return Value
Returns the BASE64-encoded string.Decode_BASE64_String
Decodes a BASE64-encoded string back to its original binary data.function Decode_BASE64_String(Input: RawByteString): RawByteString;
Parameters
- Input: RawByteString; The BASE64-encoded data to decode.
Return Value
Returns the decoded binary data as a RawByteString.Encode_BASE64
Encodes the content of the input memory stream as BASE64 and writes the result to the output memory stream.procedure Encode_BASE64(Input, Output: ThMemoryStream);
Parameters
- Input: ThMemoryStream; The memory stream containing data to encode.
- Output: ThMemoryStream; The memory stream to receive the BASE64-encoded data.
Decode_BASE64
Decodes BASE64-encoded data from the source memory stream and writes the binary result to the target memory stream.Decoding is performed on the specified range of the source stream.
procedure Decode_BASE64(Source, Target: ThMemoryStream; FromPos, UntilPos: NativeUInt);
Parameters
- Source: ThMemoryStream; The memory stream containing BASE64-encoded data.
- Target: ThMemoryStream; The memory stream to receive the decoded data.
- FromPos: NativeUInt; Starting position in the source stream.
- UntilPos: NativeUInt; Ending position in the source stream.
Generate_Sapphire_Key_Array_For_Delphi
Generates a random key array suitable for use with the Sapphire encryption algorithm.Returns the key as a string for use in Delphi code.
function Generate_Sapphire_Key_Array_For_Delphi(KeyLen: Integer): String;
Parameters
- KeyLen: Integer; The desired length of the key array.
Return Value
Returns a string representing the generated Sapphire key array.Test_Does_String_Contain_Only_BASE64_Chars
Checks if the input string contains only valid BASE64 characters.Returns a Boolean indicating the result.
function Test_Does_String_Contain_Only_BASE64_Chars(const Input: String): Boolean;
Parameters
- Input: String; The string to check for BASE64 validity.
Return Value
Returns True if the string contains only BASE64 characters.Returns False otherwise.