mirror of https://github.com/mono/CppSharp.git
2 changed files with 0 additions and 86 deletions
@ -1,52 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Runtime.Serialization.Formatters.Binary; |
|
||||||
|
|
||||||
[Serializable] |
|
||||||
class FileHashes |
|
||||||
{ |
|
||||||
private string serializedFile; |
|
||||||
private Dictionary<string, int> fileHashes = new Dictionary<string, int>(); |
|
||||||
|
|
||||||
public bool UpdateHash(string file, int hash) |
|
||||||
{ |
|
||||||
if(!fileHashes.ContainsKey(file)) |
|
||||||
{ |
|
||||||
fileHashes.Add(file, hash); |
|
||||||
Save(this, serializedFile); |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
var oldHash = fileHashes[file]; |
|
||||||
fileHashes[file] = hash; |
|
||||||
Save(this, serializedFile); |
|
||||||
|
|
||||||
return oldHash != hash; |
|
||||||
} |
|
||||||
|
|
||||||
public static FileHashes Load(string file) |
|
||||||
{ |
|
||||||
var stream = File.Open(file, FileMode.OpenOrCreate); |
|
||||||
var bformatter = new BinaryFormatter(); |
|
||||||
|
|
||||||
FileHashes obj; |
|
||||||
if(stream.Length>0) |
|
||||||
obj = (FileHashes)bformatter.Deserialize(stream); |
|
||||||
else |
|
||||||
obj = new FileHashes(); |
|
||||||
obj.serializedFile = file; |
|
||||||
stream.Close(); |
|
||||||
|
|
||||||
return obj; |
|
||||||
} |
|
||||||
|
|
||||||
public static void Save(FileHashes obj, string file) |
|
||||||
{ |
|
||||||
Stream stream = File.Open(file, FileMode.Create); |
|
||||||
BinaryFormatter bformatter = new BinaryFormatter(); |
|
||||||
|
|
||||||
bformatter.Serialize(stream, obj); |
|
||||||
stream.Close(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,34 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
|
|
||||||
public static class Glob |
|
||||||
{ |
|
||||||
static public string[] GetFiles(string[] patterns) |
|
||||||
{ |
|
||||||
List<string> filelist = new List<string>(); |
|
||||||
foreach (string pattern in patterns) |
|
||||||
filelist.AddRange(GetFiles(pattern)); |
|
||||||
string[] files = new string[filelist.Count]; |
|
||||||
filelist.CopyTo(files, 0); |
|
||||||
return files; |
|
||||||
} |
|
||||||
|
|
||||||
static public string[] GetFiles(string patternlist) |
|
||||||
{ |
|
||||||
List<string> filelist = new List<string>(); |
|
||||||
foreach (string pattern in |
|
||||||
patternlist.Split(Path.GetInvalidPathChars())) |
|
||||||
{ |
|
||||||
string dir = Path.GetDirectoryName(pattern); |
|
||||||
if (String.IsNullOrEmpty(dir)) dir = |
|
||||||
Directory.GetCurrentDirectory(); |
|
||||||
filelist.AddRange(Directory.GetFiles( |
|
||||||
Path.GetFullPath(dir), |
|
||||||
Path.GetFileName(pattern))); |
|
||||||
} |
|
||||||
string[] files = new string[filelist.Count]; |
|
||||||
filelist.CopyTo(files, 0); |
|
||||||
return files; |
|
||||||
} |
|
||||||
} |
|
||||||
Loading…
Reference in new issue