Single File System: Virtual File System Delphi Library
for Archive / Backup with Transparent Compression and Strong Encryption


TSFSFileStream.Create
TSFSFileStream
Top 


Creates an instance of TSFSFileStream.

constructor Create(SingleFileSystem: TSingleFileSystem; const FileName: string; Mode: Word; Password: string = ''; Question: string = ''; Answer: string = ''; compressLevel: TSFSCompressionLevel






































= sfsNone);

Description
Call Create to instantiate a file stream for reading from or writing to the named file. Specify the name of the file and the way the file should be opened as parameters.

The SingleFileSystem parameter specifies a single file which part is to be accessed as a file with specified FileName.

The Mode parameter indicates how the file is to be opened. The Mode parameter consists of an open mode and a share mode together. The open mode must be one of the following values:

Value    Meaning    
fmCreate   Create a file with the given name. If a file with the given name exists, open the file in write mode.   
fmOpenRead   Open the file for reading only.   
fmOpenWrite   Open the file for writing only. Writing to the file completely replaces the current contents.   
fmOpenReadWrite   Open the file to modify the current contents rather than replace them.   
   
The share mode must be one of the following values:

Value    Meaning    
fmShareCompat   Sharing is compatible with the way FCBs are opened.   
fmShareExclusive   Other applications cannot open the file for any reason.   
fmShareDenyWrite   Other applications can open the file for reading but not for writing.   
fmShareDenyRead   Other applications can open the file for writing but not for reading.   
fmShareDenyNone   No attempt is made to prevent other applications from reading from or writing to the file.   

If the file cannot be opened, Create raises an exception.

The Password parameter value different from default blank string indicates that the data is encrypted by this password. This parameter is required to create an encrypted compressed file or to open an existing encrypted file. If the encrypted file is open and the Password doesn't match the password that was used to encrypt the file then Create raises an exception

The Question parameter indicates a question that may be asked if a user forgot his / her password to recover the password.

The Answer parameter indicates an answer that must be given by a user to recover his/her forgotten password.

The CompressLevel indicates the level of compression to be used for the created stream. If you open the existing file TSFSFileStream detects it if this is a SFS compressed file or normal file and if it's an SFS file the compression level is determined. If this file is a normal non-compressed file then it is simply opened and the CompressionLevel property is set to sfsNone.

Note:
If you want to know if the compressed file is encrypted, i.e. password protected before opening it you may use the IsFileEncrypted function of TSingleFileSystem.
If you want to know if the password is valid before opening a file you may use the IsPasswordValid function of TSingleFileSystem.
If the password is not specified or invalid, then TSingleFileSystem.OnPassword event is fired.



© 2000-2004 AidAim Software LLC Single File System: Single-file Delphi Virtual File Syste