* Added new compatibility functions to Util
* IsEnvironmentSupported() - returns whether the platform is supported, if not, an error message is specified (at the moment restricts 95/98/ME, Systems that lack HTTPD.SYS and versions of the .NET framework prior to 2.0) * GetFileName() - returns a system valid filename, on windows this places data in the Application Data directory, on UNIX, the folder in which the application is calling from.afrisby
parent
c33b29a105
commit
43507f857b
|
@ -63,6 +63,61 @@ namespace OpenSim.Framework.Utilities
|
|||
return id;
|
||||
}
|
||||
|
||||
public static string GetFileName(string file)
|
||||
{
|
||||
// Return just the filename on UNIX platforms
|
||||
// TODO: this should be customisable with a prefix, but that's something to do later.
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
// Return %APPDATA%/OpenSim/file for 2K/XP/NT/2K3/VISTA
|
||||
// TODO: Switch this to System.Enviroment.SpecialFolders.ApplicationData
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
{
|
||||
if (!System.IO.Directory.Exists("%APPDATA%\\OpenSim\\"))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory("%APPDATA%\\OpenSim");
|
||||
}
|
||||
|
||||
return "%APPDATA%\\OpenSim\\" + file;
|
||||
}
|
||||
|
||||
// Catch all - covers older windows versions
|
||||
// (but those probably wont work anyway)
|
||||
return file;
|
||||
}
|
||||
|
||||
public static bool IsEnvironmentSupported(ref string reason)
|
||||
{
|
||||
// Must have .NET 2.0 (Generics / libsl)
|
||||
if (System.Environment.Version.Major < 2)
|
||||
{
|
||||
reason = ".NET 1.0/1.1 lacks components that is used by OpenSim";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Windows 95/98/ME are unsupported
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Win32Windows &&
|
||||
System.Environment.OSVersion.Platform != PlatformID.Win32NT)
|
||||
{
|
||||
reason = "Windows 95/98/ME will not run OpenSim";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Windows 2000 / Pre-SP2 XP
|
||||
if (System.Environment.OSVersion.Version.Major == 5 && (
|
||||
System.Environment.OSVersion.Version.Minor == 0 ||
|
||||
System.Environment.OSVersion.ServicePack == "Service Pack 1"))
|
||||
{
|
||||
reason = "Please update to Windows XP Service Pack 2 or Server2003";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int UnixTimeSinceEpoch()
|
||||
{
|
||||
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
|
||||
|
|
Loading…
Reference in New Issue