mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD/StashFS: step-1: base uStashFilesBackend
This commit is contained in:
parent
7f6e77ae73
commit
844cfd64a8
1 changed files with 84 additions and 0 deletions
84
src/filesources/stash/ustashfilesbackend.pas
Normal file
84
src/filesources/stash/ustashfilesbackend.pas
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
unit uStashFilesBackend;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
uFile, uFileSystemFileSource;
|
||||
|
||||
type
|
||||
|
||||
{ TStashFilesBackend }
|
||||
|
||||
TStashFilesBackend = class
|
||||
private
|
||||
_paths: TStringList;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure addPath( const path: String );
|
||||
procedure removePath( const path: String );
|
||||
procedure clear;
|
||||
function toFiles: TFiles;
|
||||
end;
|
||||
|
||||
var
|
||||
stashFilesBackend: TStashFilesBackend;
|
||||
|
||||
implementation
|
||||
|
||||
{ TStashFilesBackend }
|
||||
|
||||
constructor TStashFilesBackend.Create;
|
||||
begin
|
||||
_paths:= TStringList.Create;
|
||||
end;
|
||||
|
||||
destructor TStashFilesBackend.Destroy;
|
||||
begin
|
||||
FreeAndNIl( _paths );
|
||||
end;
|
||||
|
||||
procedure TStashFilesBackend.addPath(const path: String);
|
||||
begin
|
||||
_paths.Add( path );
|
||||
end;
|
||||
|
||||
procedure TStashFilesBackend.removePath(const path: String);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i:= _paths.IndexOf( path );
|
||||
if i >= 0 then
|
||||
_paths.Delete( i );
|
||||
end;
|
||||
|
||||
procedure TStashFilesBackend.clear;
|
||||
begin
|
||||
_paths.Clear;
|
||||
end;
|
||||
|
||||
function TStashFilesBackend.toFiles: TFiles;
|
||||
var
|
||||
files: TFiles;
|
||||
path: String;
|
||||
f: TFile;
|
||||
begin
|
||||
files:= TFiles.Create( EmptyStr );
|
||||
for path in _paths do begin
|
||||
f:= TFileSystemFileSource.CreateFileFromFile( path );
|
||||
files.Add( f );
|
||||
end;
|
||||
Result:= files;
|
||||
end;
|
||||
|
||||
initialization
|
||||
stashFilesBackend:= TStashFilesBackend.Create;
|
||||
|
||||
finalization
|
||||
FreeAndNil( stashFilesBackend );
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue