Last change
on this file since 388 was 351, checked in by alloc, 6 years ago |
Fixed game version compatibility of GamePrefs
Code style cleanup (mostly argument names)
|
File size:
739 bytes
|
Rev | Line | |
---|
[199] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.IO;
|
---|
| 4 |
|
---|
[325] | 5 | namespace AllocsFixes.FileCache {
|
---|
[199] | 6 | // Caching all files, useful for completely static folders only
|
---|
[325] | 7 | public class SimpleCache : AbstractCache {
|
---|
| 8 | private readonly Dictionary<string, byte[]> fileCache = new Dictionary<string, byte[]> ();
|
---|
[199] | 9 |
|
---|
[351] | 10 | public override byte[] GetFileContent (string _filename) {
|
---|
[199] | 11 | try {
|
---|
| 12 | lock (fileCache) {
|
---|
[351] | 13 | if (!fileCache.ContainsKey (_filename)) {
|
---|
| 14 | if (!File.Exists (_filename)) {
|
---|
[199] | 15 | return null;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
[351] | 18 | fileCache.Add (_filename, File.ReadAllBytes (_filename));
|
---|
[199] | 19 | }
|
---|
| 20 |
|
---|
[351] | 21 | return fileCache [_filename];
|
---|
[199] | 22 | }
|
---|
| 23 | } catch (Exception e) {
|
---|
| 24 | Log.Out ("Error in SimpleCache.GetFileContent: " + e);
|
---|
| 25 | }
|
---|
[325] | 26 |
|
---|
[199] | 27 | return null;
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
[325] | 30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.