public FileSystemCasBlobWriter(FileSystemCasConnection connection)
{
if (connection == null) throw new ArgumentNullException("connection");
this.connection = connection;
hash = connection.hashName == null ? new SHA1CryptoServiceProvider() : HashAlgorithm.Create(connection.hashName);
if (hash == null) throw new Exception("Missing hash algorithm: " + connection.hashName);
Random r = new Random();
string temp;
int i = 0;
do
{
if (i > 100) throw new Exception("Unable to find a random temporary filename for writing.");
temp = Path.Combine(connection.path, FileSystemCasConnection.TEMPFILEBASE + r.Next().ToString("x"));
i++;
}
while (File.Exists(temp));
tempStream = new FileStream(temp, FileMode.Create, FileAccess.Write, FileShare.None);
tempFile = temp;
}