private static KecaknoahFunctionResult ClassSplit(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args) { var sa = args.ExpectString(3, false); var result = Regex.Split(sa[0], sa[1]); return result.ToKecaknoahArray().NoResume(); }
private static KecaknoahFunctionResult ClassReplace(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args) { var sa = args.ExpectString(3, false); var result = Regex.Replace(sa[0], sa[1], sa[2]); return result.AsKecaknoahString().NoResume(); }
private static KecaknoahFunctionResult ClassGetFiles(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args) { var sarg = args.ExpectString(1, true); if (sarg.Count >= 2) { var list = Directory.GetFiles(sarg[0], sarg[1]); return new KecaknoahArray(list.Select(p => p.AsKecaknoahString())).NoResume(); } else { var list = Directory.GetFiles(sarg[0]); return new KecaknoahArray(list.Select(p => p.AsKecaknoahString())).NoResume(); } }
private static KecaknoahFunctionResult ClassDeleteDirectory(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args) { var sarg = args.ExpectString(1, false); Directory.Delete(sarg[0]); return KecaknoahNil.Instance.NoResume(); }
private static KecaknoahFunctionResult ClassExists(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args) { var sarg = args.ExpectString(1, false); return Directory.Exists(sarg[0]).AsKecaknoahBoolean().NoResume(); }
private static KecaknoahFunctionResult ClassReadText(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args) { var sarg = args.ExpectString(1, true); var result = ""; if (sarg.Count >= 2) { result = File.ReadAllText(sarg[0], Encoding.GetEncoding(sarg[1])); } else { result = File.ReadAllText(sarg[0]); } return KecaknoahNil.Instance.NoResume(); }
private static KecaknoahFunctionResult ClassWriteText(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args) { var sarg = args.ExpectString(2, true); if (sarg.Count >= 3) { File.WriteAllText(sarg[0], sarg[1], Encoding.GetEncoding(sarg[2])); } else { File.WriteAllText(sarg[0], sarg[1]); } return KecaknoahNil.Instance.NoResume(); }