Imports System Imports System.Reflection Imports System.IO Imports System.Text 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 Public Function HashToHex(hash As String) As String Dim hexString As New StringBuilder(hash.Length) For i As Integer = 0 To hash.Length - 1 Dim c As Char = CChar(hash(i)) Dim b As Byte = CByte(c) hexString.Append(b.ToString("X2")) Next Return hexString.ToString() End Function 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 End Namespace