public SymlinkTreeEntry (Tree myParent, SHA1 objId, string objName, bool exec) : 
			base (myParent, objId, objName)
		{
			mode = GitFileMode.Symlink;
		}
Esempio n. 2
0
		/// <summary>
		/// This means that is a tree that doesn't cotains children trees
		/// </summary>
		/// <param name="tree">
		/// A <see cref="Tree"/>
		/// </param>
		/// <param name="store">
		/// A <see cref="ObjectStore"/>
		/// </param>
		/// <returns>
		/// A <see cref="System.Boolean"/>
		/// </returns>
		protected static bool IsLastChild (Tree tree, ObjectStore store)
		{
			foreach (TreeEntry entry in tree.Entries) {
				if (store.Get (entry.Id).Type == Type.Tree)
					return false;
			}
			
			return true;
		}
Esempio n. 3
0
		public void ReadTree (string prefix, Tree tree, Repo repo)
		{
			TreeEntry[] treeEntries = tree.Entries;
			
			foreach (TreeEntry te in treeEntries) {
				string name;
				
				if (!String.IsNullOrEmpty (prefix))
					name = String.Format ("{0}/{1}", prefix, te.Name);
				else
					name = te.Name;
				
//				if (te.IsTree (repo))
//					ReadTree (name, tree, repo);
			}
		}
Esempio n. 4
0
		public void ReadTree (Tree tree, Repo repo)
		{
			ReadTree ("", tree, repo);
		}
		public BlobTreeEntry (Tree myParent, SHA1 objId, string objName, bool exec) : 
			base (myParent, objId, objName)
		{
			SetExecutable (exec);
		}
		/// <summary>
		/// Get a tree and create the structure from there
		/// </summary>
		/// <param name="gitDir">
		/// A <see cref="System.String"/>
		/// </param>
		/// <param name="tree">
		/// A <see cref="Tree"/>
		/// </param>
		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 ();
			}
		}
		private void LsTree (Tree tree)
		{
			Console.Write (tree);
		}