GitSharp.Core.DirectoryCache.DirCache.write C# (CSharp) Method

write() public method

Write the entry records from memory to disk. The cache must be locked first by calling Lock() and receiving true as the return value. Applications are encouraged to lock the index, then invoke read() to ensure the in-memory data is current, prior to updating the in-memory entries. Once written the lock is closed and must be either committed with commit() or rolled back with unlock().
/// The output file could not be created. The caller no longer /// holds the lock. ///
public write ( ) : void
return void
		public void write()
		{
			LockFile tmp = _myLock;
			RequireLocked(tmp);
			try
			{
				WriteTo(tmp.GetOutputStream());
			}
			catch (Exception)
			{
				tmp.Unlock();
				throw;
			}
		}

Usage Example

Example #1
0
 ///	<summary>
 /// Finish, write, commit this change, and release the index lock.
 /// <para />
 /// If this method fails (returns false) the lock is still released.
 /// <para />
 /// This is a utility method for applications as the finish-write-commit
 /// pattern is very common after using a builder to update entries.
 /// </summary>
 /// <returns>
 /// True if the commit was successful and the file contains the new
 /// data; false if the commit failed and the file remains with the
 /// old data.
 /// </returns>
 /// <exception cref="IOException">
 /// The output file could not be created. The caller no longer
 /// holds the lock.
 /// </exception>
 public virtual bool commit()
 {
     finish();
     _cache.write();
     return(_cache.commit());
 }