示例#1
0
        public ReplHistory()
        {
            cursor   = 0;
            lines    = new List <string>();
            histfile = null;

            var app = "kiezellisp";
            var dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "kiezellisp");

            if (!Directory.Exists(dir))
            {
                try
                {
                    Directory.CreateDirectory(dir);
                }
                catch
                {
                    app = null;
                }
            }

            if (app != null)
            {
                histfile = PathExtensions.Combine(dir, app) + ".history";

                if (File.Exists(histfile))
                {
                    foreach (var ln in File.ReadAllLines(histfile))
                    {
                        lines.Add(ln.Replace("<CRLF>", "\n"));
                    }
                    cursor = lines.Count;
                }
            }
        }
示例#2
0
        public static string GetApplicationInitFile()
        {
            // application config file is same folder as kiezellisp-lib.dll
            var assembly = Assembly.GetExecutingAssembly();
            var root     = assembly.Location;
            var dir      = Path.GetDirectoryName(root);

            return(PathExtensions.Combine(dir, "kiezellisp-init"));
        }
示例#3
0
        public TerminalHistory(string app = "kiezellisp")
        {
            if (app != null)
            {
                string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

                if (!Directory.Exists(dir))
                {
                    try
                    {
                        Directory.CreateDirectory(dir);
                    }
                    catch
                    {
                        app = null;
                    }
                }
                if (app != null)
                {
                    histfile = PathExtensions.Combine(dir, app) + ".history";
                }
            }

            lines  = new Vector();
            cursor = 0;

            if (File.Exists(histfile))
            {
                using (StreamReader sr = File.OpenText(histfile))
                {
                    StringBuilder buf = new StringBuilder();
                    string        line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line != "")
                        {
                            if (line[0] == '\x1F')
                            {
                                Append(buf.ToString());
                                buf.Length = 0;
                            }
                            else
                            {
                                if (buf.Length != 0)
                                {
                                    buf.Append('\n');
                                }
                                buf.Append(line);
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        public static string FindFileInPath(string fileName)
        {
            var folders = (Cons)GetDynamic(Symbols.AssemblyPath);

            foreach (string s in ToIter(folders))
            {
                var p = PathExtensions.Combine(s, fileName);
                if (File.Exists(p))
                {
                    return(p);
                }
            }
            return(fileName);
        }
示例#5
0
        public static string FindOneOfSourceFiles(IEnumerable names, IEnumerable folders)
        {
            var names2 = new List <string>();

            foreach (string file in ToIter(names))
            {
                if (Path.IsPathRooted(file))
                {
                    if (File.Exists(file))
                    {
                        return(NormalizePath(file));
                    }
                }
                else
                {
                    names2.Add(file);
                }
            }

            if (true)
            {
                var dir = Environment.CurrentDirectory;
                if (!string.IsNullOrEmpty(dir))
                {
                    foreach (string file in ToIter(names2))
                    {
                        var path = NormalizePath(PathExtensions.Combine(dir, file));
                        if (File.Exists(path))
                        {
                            return(path);
                        }
                    }
                }
            }

            foreach (string dir in ToIter(folders))
            {
                foreach (string file in ToIter(names2))
                {
                    var path = NormalizePath(PathExtensions.Combine(dir, file));
                    if (File.Exists(path))
                    {
                        return(path);
                    }
                }
            }

            return(null);
        }
示例#6
0
        public ReplHistory()
        {
            cursor   = 0;
            lines    = new List <string>();
            histfile = null;

            var dir = Runtime.CreateKiezellispDataFolder();

            histfile = PathExtensions.Combine(dir, "kiezellisp.history");

            if (File.Exists(histfile))
            {
                foreach (var ln in File.ReadAllLines(histfile))
                {
                    lines.Add(ln.Replace("<CRLF>", "\n"));
                }
                cursor = lines.Count;
            }
        }
示例#7
0
        public static string GetApplicationInitFile()
        {
            var dir = CreateKiezellispDataFolder();

            return(PathExtensions.Combine(dir, "kiezellisp-init.k"));
        }