-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStorageIntf.cpp
More file actions
86 lines (77 loc) · 2.49 KB
/
StorageIntf.cpp
File metadata and controls
86 lines (77 loc) · 2.49 KB
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
80
81
82
83
84
85
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee <dee@kikyou.info> and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Universal Storage System
//---------------------------------------------------------------------------
#include "tp_stub.h"
#include "StorageIntf.h"
#include "hook_init.h"
class tTVPFileMedia : public iTVPStorageMedia
{
tjs_uint RefCount;
iTVPStorageMedia *FileMedia;
public:
tTVPFileMedia(iTVPStorageMedia* media) {
media->AddRef();
FileMedia = media;
RefCount = 1;
}
~tTVPFileMedia() {
FileMedia->Release();
}
void TJS_INTF_METHOD AddRef() { RefCount++; }
void TJS_INTF_METHOD Release()
{
if (RefCount == 1)
delete this;
else
RefCount--;
}
void TJS_INTF_METHOD GetName(ttstr &name) { name = TJS_W("file"); }
void TJS_INTF_METHOD NormalizeDomainName(ttstr &name) {
FileMedia->NormalizeDomainName(name);
}
void TJS_INTF_METHOD NormalizePathName(ttstr &name) {
FileMedia->NormalizePathName(name);
}
bool TJS_INTF_METHOD CheckExistentStorage(const ttstr &name) {
return FileMedia->CheckExistentStorage(name);
}
tTJSBinaryStream * TJS_INTF_METHOD Open(const ttstr & name, tjs_uint32 flags);
void TJS_INTF_METHOD GetListAt(const ttstr &name, iTVPStorageLister *lister) {
return FileMedia->GetListAt(name, lister);
}
void TJS_INTF_METHOD GetLocallyAccessibleName(ttstr &name) {
return FileMedia->GetLocallyAccessibleName(name);
}
bool TJS_INTF_METHOD GetFileSystemChanged() {
return FileMedia->GetFileSystemChanged();
}
};
//---------------------------------------------------------------------------
tTJSBinaryStream * TJS_INTF_METHOD tTVPFileMedia::Open(const ttstr & name, tjs_uint32 flags)
{
// open storage named "name".
// currently only local/network(by OS) storage systems are supported.
// if (name.IsEmpty())
// TVPThrowExceptionMessage(TVPCannotOpenStorage, TJS_W("\"\""));
//
// ttstr origname = name;
// ttstr _name(name);
// GetLocalName(_name);
//
// return new tTVPLocalFileStream(origname, _name, flags);
return nullptr;
}
void InstallStorageMedia(MediaStorageHashTable* pTable) {
iTVPStorageMedia* pMedia = pTable->GetFirst().GetValue().MediaIntf.GetObjectNoAddRef();
ttstr name;
pMedia->GetName(name);
tTVPFileMedia *filemedia = new tTVPFileMedia(pMedia);
TVPUnregisterStorageMedia(pMedia);
TVPRegisterStorageMedia(filemedia);
}