// NAnt - A .NET build tool
// Copyright (C) 2001-2004 Gerry Shaw
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Gert Driesen (gert.driesen@ardatis.com)
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using NAnt.Core;
using NAnt.Core.Types;
using NAnt.Core.Attributes;
namespace NAnt.Core.Functions {
///
/// Functions that provide version information for a physical file on disk.
///
[FunctionSet("fileversioninfo", "Version")]
public class FileVersionInfoFunctions : FunctionSetBase {
#region Public Instance Constructors
public FileVersionInfoFunctions(Project project, PropertyDictionary properties) : base(project, properties) {}
#endregion Public Instance Constructors
#region Public Instance Methods
///
/// Returns a representing the version
/// information associated with the specified file.
///
/// The file to retrieve the version information for.
///
/// A containing information about the file.
///
/// The file specified cannot be found.
[Function("get-version-info")]
public FileVersionInfo GetVersionInfo(string fileName) {
return FileVersionInfo.GetVersionInfo(
Project.GetFullPath(fileName));
}
#endregion Public Instance Methods
#region Public Static Methods
///
/// Gets the name of the company that produced the file.
///
/// A instance containing version information about a file.
///
/// The name of the company that produced the file.
///
[Function("get-company-name")]
public static string GetCompanyName(FileVersionInfo fileVersionInfo) {
return fileVersionInfo.CompanyName;
}
///
/// Gets the file version of a file.
///
/// A instance containing version information about a file.
///
/// The file version of a file.
///
///
[Function("get-file-version")]
public static Version GetFileVersion(FileVersionInfo fileVersionInfo) {
return new Version(fileVersionInfo.FileMajorPart, fileVersionInfo.FileMinorPart,
fileVersionInfo.FileBuildPart, fileVersionInfo.FilePrivatePart);
}
///
/// Gets the name of the product the file is distributed with.
///
/// A instance containing version information about a file.
///
/// The name of the product the file is distributed with.
///
[Function("get-product-name")]
public static string GetProductName(FileVersionInfo fileVersionInfo) {
return fileVersionInfo.ProductName;
}
///
/// Gets the product version of a file.
///
/// A instance containing version information about a file.
///
/// The product version of a file.
///
///
[Function("get-product-version")]
public static Version GetProductVersion(FileVersionInfo fileVersionInfo) {
return new Version(fileVersionInfo.ProductMajorPart, fileVersionInfo.ProductMinorPart,
fileVersionInfo.ProductBuildPart, fileVersionInfo.ProductPrivatePart);
}
#endregion Public Static Methods
}
}