|
- unit uvfsUtils;
-
- {$mode objfpc}{$H+}
-
- interface
-
- uses
- Classes, SysUtils;
-
- {
- type
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TvfsFileWriter = class(TInterfacedObject, IutlFileWriter)
- public
- procedure SaveStream(const aFilename: String; const aStream: TStream);
- end;
-
- TvfsFileReader = class(TInterfacedObject, IutlFileReader)
- public
- function LoadStream(const aFilename: String; const aStream: TStream): Boolean;
- end;
- }
- implementation
-
- uses
- uvfsManager;
- {
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //TvfsFileReader////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- function TvfsFileReader.LoadStream(const aFilename: String; const aStream: TStream): Boolean;
- var
- s: IStreamHandle;
- begin
- result := vfsManager.ReadFile(aFilename, s);
- if result then
- aStream.CopyFrom(s, s.GetStream.Size - s.GetStream.Position);
- end;
-
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //TvfsFileWriter////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- procedure TvfsFileWriter.SaveStream(const aFilename: String; const aStream: TStream);
- var
- s: IStreamHandle;
- begin
- if not vfsManager.WriteFile(aFilename, true, s) then
- raise EvfsError.Create('unable to create file: ' + aFilename);
- s.GetStream.CopyFrom(aStream, aStream.Size - aStream.Position);
- end;
- }
- end.
|