Exemplo n.º 1
0
		/// <exception cref="System.IO.IOException"></exception>
		private void Config(string data)
		{
			OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(configFile), 
				"UTF-8");
			fw.Write(data);
			fw.Close();
		}
Exemplo n.º 2
0
 /// <summary>Write a string as a UTF-8 file.</summary>
 /// <remarks>Write a string as a UTF-8 file.</remarks>
 /// <param name="f">
 /// file to write the string to. Caller is responsible for making
 /// sure it is in the trash directory or will otherwise be cleaned
 /// up at the end of the test. If the parent directory does not
 /// exist, the missing parent directories are automatically
 /// created.
 /// </param>
 /// <param name="body">content to write to the file.</param>
 /// <exception cref="System.IO.IOException">the file could not be written.</exception>
 public static void Write(FilePath f, string body)
 {
     FileUtils.Mkdirs(f.GetParentFile(), true);
     TextWriter w = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
     try
     {
         w.Write(body);
     }
     finally
     {
         w.Close();
     }
 }
Exemplo n.º 3
0
		/// <summary>Format this builder's state as an annotated tag object.</summary>
		/// <remarks>Format this builder's state as an annotated tag object.</remarks>
		/// <returns>
		/// this object in the canonical annotated tag format, suitable for
		/// storage in a repository.
		/// </returns>
		public virtual byte[] Build()
		{
			ByteArrayOutputStream os = new ByteArrayOutputStream();
			OutputStreamWriter w = new OutputStreamWriter(os, Constants.CHARSET);
			try
			{
				w.Write("object ");
				GetObjectId().CopyTo(w);
				w.Write('\n');
				w.Write("type ");
				w.Write(Constants.TypeString(GetObjectType()));
				w.Write("\n");
				w.Write("tag ");
				w.Write(GetTag());
				w.Write("\n");
				if (GetTagger() != null)
				{
					w.Write("tagger ");
					w.Write(GetTagger().ToExternalString());
					w.Write('\n');
				}
				w.Write('\n');
				if (GetMessage() != null)
				{
					w.Write(GetMessage());
				}
				w.Close();
			}
			catch (IOException err)
			{
				// This should never occur, the only way to get it above is
				// for the ByteArrayOutputStream to throw, but it doesn't.
				//
				throw new RuntimeException(err);
			}
			return os.ToByteArray();
		}
Exemplo n.º 4
0
 /// <exception cref="System.IO.IOException"></exception>
 private void UpdateFETCH_HEAD(FetchResult result)
 {
     FilePath meta = transport.local.Directory;
     if (meta == null)
     {
         return;
     }
     LockFile Lock = new LockFile(new FilePath(meta, "FETCH_HEAD"), transport.local.FileSystem
         );
     try
     {
         if (Lock.Lock())
         {
             TextWriter w = new OutputStreamWriter(Lock.GetOutputStream());
             try
             {
                 foreach (FetchHeadRecord h in fetchHeadUpdates)
                 {
                     h.Write(w);
                     result.Add(h);
                 }
             }
             finally
             {
                 w.Close();
             }
             Lock.Commit();
         }
     }
     finally
     {
         Lock.Unlock();
     }
 }