This repository has been archived by the owner on May 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfsarchive.pas
79 lines (59 loc) · 1.42 KB
/
fsarchive.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
archive handler
c:\windows\hene\hede.zip\hene.dir\hede
openfs called with url of archive name and directories are added as needed
this way parents should work better
}
unit fsarchive;
interface
uses
fs,
SysUtils, Classes;
type
TArchiveFSHandler = class(TFSHandler)
protected
Base : string;
Stream : TStream;
function getSubPath:string;
public
procedure OpenFS(const url:string);override;
procedure CloseFS;override;
function contentsChanged:boolean;override;
procedure setParent;override;
end;
implementation
{ TArchiveFSHandler }
function TArchiveFSHandler.getSubPath;
begin
with Info do
if pos(UpperCase(Base),UpperCase(Path)) = 0 then
Result := System.copy(Path,length(Base)+1,length(Path))
else
raise EFSException.Create(Format('Path<->Base inconsistent "%s"/"%s"',
[Path,Base]));
end;
procedure TArchiveFSHandler.OpenFS(const url: string);
begin
Base := url;
Stream := TFileStream.Create(url,fmOpenRead);
setPath(IncludeTrailingPathDelimiter(url));
end;
procedure TArchiveFSHandler.CloseFS;
begin
Stream.Free;
end;
function TArchiveFSHandler.contentsChanged: boolean;
begin
Result := false;
end;
procedure TArchiveFSHandler.setParent;
var
pnew:string;
begin
pnew := ExtractFilePath(ExcludeTrailingPathDelimiter(Info.Path));
if length(pnew) < length(Base) then
raise EFSChangeRequired.Create(pnew)
else
setPath(pnew);
end;
end.