Пример #1
0
 private int __total() //MB単位
 {
     if (NWEnviroment.isWindows())
     {
         float                      total = 0;
         ManagementClass            mc    = new ManagementClass("Win32_OperatingSystem");
         ManagementObjectCollection moc   = mc.GetInstances();
         foreach (ManagementObject mo in moc)
         {
             total = (int.Parse(mo["TotalVisibleMemorySize"].ToString()) + int.Parse(mo["TotalVirtualMemorySize"].ToString())) / 1000;
         }
         moc.Dispose();
         mc.Dispose();
         return((int)total);
     }
     else
     {
         string free = LinuxCommand.execute("free -m");
         using (StringReader sr = new StringReader(free)){
             string line = "";
             while ((line = sr.ReadLine()) != null)
             {
                 if (line.Contains("-/+"))
                 {
                     string[] parts = Regex.Split(line, @"\s+");
                     int      total = int.Parse(parts[parts.Length - 1]) + int.Parse(parts[parts.Length - 2]);
                     sr.Close();
                     sr.Dispose();
                     return(total);
                 }
             }
         }
     }
     return(0);//TODO: Exception?
 }
Пример #2
0
        private int __available() //MB単位
        {
            if (NWEnviroment.isWindows())
            {
                string mem      = "Memory";
                string countMem = "Available Mbytes";
                System.Diagnostics.PerformanceCounter pcMem = new System.Diagnostics.PerformanceCounter(mem, countMem);
                float available = pcMem.NextValue();
                pcMem.Close();
                pcMem.Dispose();
                return((int)available);
            }
            else
            {
                string free = LinuxCommand.execute("free -m");
                using (StringReader sr = new StringReader(free)){
                    string line = "";
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.Contains("-/+"))
                        {
                            string[] parts     = Regex.Split(line, @"\s+");
                            int      available = int.Parse(parts[parts.Length - 1]);
                            sr.Close();
                            sr.Dispose();
                            return(available);
//                            Console.WriteLine("rate:{0}",(int)(100*int.Parse(parts[2])/(int.Parse(parts[3])+int.Parse(parts[2]))));
                        }
                    }
                }
            }
            return(0);//TODO: Exception?
        }
Пример #3
0
        private object _toKana(INakoFuncCallInfo info)
        {
            string s = info.StackPopAsString();

            if (NWEnviroment.isWindows())
            {
                return(Strings.StrConv(s, VbStrConv.Hiragana, 0));
            }
            else
            {
                return(LinuxCommand.execute("echo '" + s + "' | nkf --hiragana").Replace("\n", ""));
            }
        }
Пример #4
0
 public void TestEnumWindows()
 {
     if (NWEnviroment.isWindows())
     {
         runner.Run(com.WriteIL(
                        "窓列挙して表示。\n"));
         Assert.AreNotEqual("", runner.PrintLog);
     }
     else
     {
         Assert.Pass("Windows環境でないのでスキップ");
     }
 }
Пример #5
0
        public void Test_driveType()
        {
            string driveName = @"C:\";

            if (!NWEnviroment.isWindows())
            {
                driveName = @"/";
            }
            runner.Run(com.WriteIL(
                           "S=「" + driveName + "」のドライブ種類\n" +
                           "Sを継続表示\n" +
                           ""));
            Assert.AreEqual("Fixed", runner.PrintLog);
        }
Пример #6
0
 public void TestClipboad2()
 {
     if (NWEnviroment.isWindows())
     {
         runner.Run(com.WriteIL(
                        "10をコピー。\n" +
                        "クリップボードを表示。"));
         Assert.AreEqual("10", runner.PrintLog);
     }
     else
     {
         Assert.Pass("Windows環境でないのでスキップ");
     }
 }
Пример #7
0
        private object _alnumToEn(INakoFuncCallInfo info)
        {
            string s = info.StackPopAsString();

            return(Regex.Replace(s, @"[0-9A-Za-z:- ]+", delegate(Match m){
                if (NWEnviroment.isWindows())
                {
                    return Strings.StrConv(m.Value, VbStrConv.Narrow, 0);
                }
                else
                {
                    return LinuxCommand.execute("echo '" + m.Value + "' | nkf -Z3").Replace("\n", "");
                }
            }));
        }
Пример #8
0
        public Object _execCommandAndGetResult(INakoFuncCallInfo info)
        {
            string s   = info.StackPopAsString();
            string ret = "";

            if (NWEnviroment.isWindows())
            {
                ret = WindowsCommand.execute(s);
            }
            else
            {
                ret = LinuxCommand.execute(s);
            }
            return(ret);
        }
Пример #9
0
 public void TestPs()//TODO:Success test
 {
     runner.Run(com.WriteIL(
                    "プロセス列挙して表示。\n"));
     Assert.AreEqual(true, runner.PrintLog.Contains((NWEnviroment.isWindows())? "svchost" : "mono"));
 }