-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStorageIntf.h
86 lines (75 loc) · 2.17 KB
/
StorageIntf.h
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
86
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee <[email protected]> and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Universal Storage System
//---------------------------------------------------------------------------
#ifndef StorageIntfH
#define StorageIntfH
#include "tp_stub.h"
#include <vector>
#include "hook_init.h"
class tMediaRecord
{
public:
class tHashFunc
{
public:
static tjs_uint32 Make(const ttstr &key)
{
if (key.IsEmpty()) return 0;
const tjs_char *str = key.c_str();
tjs_uint32 ret = 0;
while (*str && *str != ':')
{
ret += *str;
ret += (ret << 10);
ret ^= (ret >> 6);
str++;
}
ret += (ret << 3);
ret ^= (ret >> 11);
ret += (ret << 15);
if (!ret) ret = (tjs_uint32)-1;
return ret;
}
};
ttstr CurrentDomain;
ttstr CurrentPath;
tTJSRefHolder<iTVPStorageMedia> MediaIntf;
tjs_int MediaNameLen;
// bool IsCaseSensitive;
tMediaRecord(iTVPStorageMedia *media) : MediaIntf(media), CurrentDomain("."), CurrentPath("/")
{
ttstr name;
media->GetName(name); MediaNameLen = name.GetLen();
/*IsCaseSensitive = media->IsCaseSensitive();*/
}
const tjs_char *GetDomainAndPath(const ttstr &name)
{
return name.c_str() + MediaNameLen + 3;
// 3 = strlen("://")
}
};
typedef tTJSHashTable<ttstr, tMediaRecord, tMediaRecord::tHashFunc, 16> MediaStorageHashTable;
//---------------------------------------------------------------------------
// tTJSNC_Storages : TJS Storages class
//---------------------------------------------------------------------------
// class tTJSNC_Storages : public tTJSNativeClass
// {
// typedef tTJSNativeClass inherited;
//
// public:
// tTJSNC_Storages();
// static tjs_uint32 ClassID;
//
// protected:
// tTJSNativeInstance *CreateNativeInstance();
// };
// //---------------------------------------------------------------------------
// extern tTJSNativeClass * TVPCreateNativeClass_Storages();
//---------------------------------------------------------------------------
#endif