This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +36
-0
lines changed Expand file tree Collapse file tree 5 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -58,5 +58,7 @@ protected void OnLoaded()
58
58
public abstract bool Exists ( string filename ) ;
59
59
60
60
public abstract byte [ ] ReadAllBytes ( string filename ) ;
61
+
62
+ public abstract Stream OpenRead ( string filename ) ;
61
63
}
62
64
}
Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ public override byte[] ReadAllBytes(string filename)
51
51
{
52
52
return _bundle . ReadAllBytes ( filename ) ;
53
53
}
54
+
55
+ public override Stream OpenRead ( string filename )
56
+ {
57
+ return _bundle . OpenRead ( filename ) ;
58
+ }
54
59
}
55
60
56
61
public class ZipArchiveUBundle : UBundle
@@ -88,6 +93,20 @@ public bool Exists(string filename)
88
93
return false ;
89
94
}
90
95
96
+ // 打开压缩包中的文件, 返回其文件流
97
+ public Stream OpenRead ( string filename )
98
+ {
99
+ if ( _zipFile != null )
100
+ {
101
+ var entry = _zipFile . GetEntry ( filename ) ;
102
+ if ( entry != null )
103
+ {
104
+ return _zipFile . GetInputStream ( entry ) ;
105
+ }
106
+ }
107
+ return null ;
108
+ }
109
+
91
110
public byte [ ] ReadAllBytes ( string filename )
92
111
{
93
112
if ( _zipFile != null )
Original file line number Diff line number Diff line change @@ -41,5 +41,10 @@ public byte[] ReadAllBytes(string filename)
41
41
{
42
42
return null ;
43
43
}
44
+
45
+ public Stream OpenRead ( string filename )
46
+ {
47
+ return null ;
48
+ }
44
49
}
45
50
}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ public interface IFileSystem
11
11
event Action < IFileSystem > completed ; // 加载完成
12
12
13
13
bool Exists ( string filename ) ;
14
+ Stream OpenRead ( string filename ) ;
14
15
byte [ ] ReadAllBytes ( string filename ) ;
15
16
}
16
17
}
Original file line number Diff line number Diff line change @@ -25,6 +25,15 @@ public override bool Exists(string filename)
25
25
return File . Exists ( Path . Combine ( _rootPath , filename ) ) ;
26
26
}
27
27
28
+ public override Stream OpenRead ( string filename )
29
+ {
30
+ if ( string . IsNullOrEmpty ( _rootPath ) )
31
+ {
32
+ return File . OpenRead ( filename ) ;
33
+ }
34
+ return File . OpenRead ( Path . Combine ( _rootPath , filename ) ) ;
35
+ }
36
+
28
37
public override byte [ ] ReadAllBytes ( string filename )
29
38
{
30
39
if ( string . IsNullOrEmpty ( _rootPath ) )
You can’t perform that action at this time.
0 commit comments