using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Logging;
namespace Tango.Protobuf
{
///
/// Represents an file compilation result.
///
///
public class CompilerFileResult : ICompilerResult
{
private LogManager logManager = LogManager.Default;
///
/// Gets the result language.
///
public CompilerLanguage Language { get; private set; }
///
/// Gets the result name.
///
public String Name { get; internal set; }
///
/// Gets the result source path.
///
public String SourcePath { get; private set; }
///
/// Gets the file content.
///
public String Content { get; internal set; }
///
/// Gets or sets the relative file path.
///
internal String RelativePath { get; private set; }
///
/// Initializes a new instance of the class.
///
/// The language.
/// The source path.
/// Name of the file.
/// File contents.
public CompilerFileResult(CompilerLanguage language, String sourcePath, String fileName, String relativePath, String content)
{
Language = language;
SourcePath = sourcePath;
Name = fileName;
RelativePath = relativePath;
Content = content;
}
///
/// Saves the result to the specified folder.
///
/// The folder.
public void Save(String folder)
{
logManager.Log("Saving " + Path.Combine(folder, Name) + "...");
Directory.CreateDirectory(folder);
File.WriteAllText(Path.Combine(folder, Name), Content);
}
///
/// Returns a that represents this instance.
///
///
/// A that represents this instance.
///
public override string ToString()
{
return Name;
}
}
}