public Checkout ( string baseDir, |
||
baseDir | string | |
tree |
/// A |
|
Результат | void |
public void Checkout(string baseDir, Tree tree)
{
for (int i = 0; i < tree.Entries.Length; i++) {
string fullPath = baseDir + "/" + tree.Entries[i].Name;
Console.WriteLine ("Entry: #{0} {1} {2}", i, tree.Entries[i].Name, tree.Entries[i].Id.ToHexString ());
if (tree.Entries[i].IsTree ()) {
if (!Directory.Exists (fullPath))
Directory.CreateDirectory (fullPath);
Checkout (fullPath, (Tree) Get (tree.Entries[i].Id));
continue;
}
FileStream fs = new FileStream (fullPath, FileMode.Create, FileAccess.Write);
Blob blobToWrite = (Blob) Get (tree.Entries[i].Id);
fs.Write (blobToWrite.Data, 0, blobToWrite.Data.Length);
// TODO: Set FileAttributes
//File.SetAttributes ("", FileAttributes.
fs.Close ();
}
}
ObjectStore::Checkout ( string baseDir, |
public static void CheckoutTest(string hash, string objStorePath) { ObjectStore store = new ObjectStore (objStorePath); SHA1 id = new SHA1 (SHA1.FromHexString (hash), false); Console.WriteLine ("Hash: " + hash); Console.WriteLine ("Id: " + id.ToHexString ()); Console.WriteLine ("hash created"); Tree tree = (Tree) store.Get (id); Console.WriteLine ("tree created No. entries: " + tree.Entries.Length); store.Checkout (Environment.CurrentDirectory, tree); Console.WriteLine ("Checkout done WIIIII!!!"); }