Imports System Imports Codice.Client.Common Imports Codice.Client.Commands Imports Codice.Client.BaseCommands Imports Codice.CM.Common Namespace Codice.Client.GlassFS Friend Class FileCache Private mBasePath As String Friend Sub New() mBasePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filecache") If Not Directory.Exists(mBasePath) Then Directory.CreateDirectory(mBasePath) End If End Sub Friend Function GetFile(repInfo As RepositoryInfo, revInfo As RevisionInfo, api As PlasticAPI) As String Dim hash As String = HashToHex(revInfo.Hash) Dim subdir As String = Path.Combine(mBasePath, String.Concat(hash(0), hash(1))) If Not Directory.Exists(subdir) Then Directory.CreateDirectory(subdir) End If Dim file__1 As String = Path.Combine(subdir, hash) If File.Exists(file__1) Then Return file__1 End If api.GetFile(repInfo, revInfo, file__1) Return file__1 End Function End Class Friend Class Hasher Friend Function HashToHex(hash As String) As String Dim hexString As New StringBuilder(hash.Length) For i As Integer = 0 To hash.Length - 1 ' modified by first user hexString.Append(CByte(CChar(hash(i))).ToString("X2")) Next Return hexString.ToString() End Function End Class End Namespace