singrdk/base/Services/Iso9660/iso9660.cs

134 lines
3.9 KiB
C#
Raw Normal View History

2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
using Console = System.Console;
using Environment = System.Environment;
using Exception = System.Exception;
using System;
using System.IO;
using System.Collections;
using System.Diagnostics;
using Int32 = System.Int32;
using IntPtr = System.IntPtr;
using System.Threading;
using System.Text;
using DateTime = System.DateTime;
using TimeSpan = System.TimeSpan;
using Hashtable = System.Collections.Hashtable;
using Microsoft.Singularity;
using Microsoft.SingSharp;
using Microsoft.Singularity.Channels;
using Microsoft.Singularity.V1.Services;
2008-11-17 18:29:00 -05:00
//
// Some utility classes and functions.
//
2008-03-05 09:52:00 -05:00
namespace Iso9660
{
public class LongId{
public static System.Int64 New(int hi, int low){
System.Int64 x = ((System.Int64)hi) << 32;
return x | (0xffff & (uint)low);
}
public static int GetHi(long id) {
return (int)(0xffffffff & (id >> 32));
}
public static int GetLo(long id) {
return (int)(0xffffffff & id);
}
public static string ToString(long x) {
return String.Format("<{0:x}:{1}>", GetHi(x), GetLo(x));
}
}
public class system {
public enum MODULE : int {SYSTEM = 0, ALLOCCLERK = 1, BTREE = 2,
NEWONES = 3};
public class Ticks {
long time;
private Ticks(long t) {
time = t;
}
public static bool operator <(Ticks x, Ticks y) {
return x.time < y.time;
}
public static bool operator >(Ticks x, Ticks y) {
return x.time > y.time;
}
public static bool operator <=(Ticks x, Ticks y) {
return x.time <= y.time;
}
public static bool operator >=(Ticks x, Ticks y) {
return x.time >= y.time;
}
public static Ticks Now {
get {
return new Ticks(DateTime.Now.Ticks);
}
}
public long DurationInMSecs(Ticks t) {
return (t.time - time + 5000)/10000;
}
public static Ticks Minimum {
get {
return new Ticks(DateTime.MinValue.Ticks);
}
}
public override string! ToString() {
DateTime d = new DateTime(this.time);
int milliseconds = d.Millisecond;
return (d.ToString () + ", " + milliseconds.ToString() + "ms");
// + " ticks= " + this.time);
}
}
public static void Assert(bool assertion) {
if (!assertion) {
2008-11-17 18:29:00 -05:00
DebugStub.WriteLine("assertion failure, stack trace:");
2008-03-05 09:52:00 -05:00
#if !SINGULARITY
StackTrace st = new StackTrace(true);
string stackIndent = "";
2008-11-17 18:29:00 -05:00
for (int i = 0; i < st.FrameCount; i++) {
2008-03-05 09:52:00 -05:00
// Low down the call stack there are four
// stack frames, one for each method invocation.
StackFrame sf = st.GetFrame(i);
Console.WriteLine("\n" + stackIndent + " Method: {0}",
sf.GetMethod() );
Console.WriteLine( stackIndent + " File: {0}", sf.GetFileName());
Console.WriteLine( stackIndent + " Line Number: {0}",
sf.GetFileLineNumber());
stackIndent += " ";
}
#endif
DebugStub.Break();
throw new Exception("Assertion failed");
}
}
public static void panic(string s) {
2008-11-17 18:29:00 -05:00
DebugStub.WriteLine("panic: {0}", __arglist(s));
2008-03-05 09:52:00 -05:00
DebugStub.Break();
throw new Exception("panic");
}
}
}