Example #1
0
        public IEnumerable <string> GetFiles(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(new List <string>());
            }

            if (name.Contains(".."))
            {
                // IMPORTANT: prevent parent paths.
                // TODO: does this catch all cases?
                return(new List <string>());
            }

            var variables = Get(name);
            var root      = variables["root"][0];
            var split     = root.IndexOf(' ');

            if (split == -1 || split == 0)
            {
                return(null);
            }

            var path    = root.Substring(split + 1);
            var winPath = Path.Combine(JexusServer.RootFolder, path.Replace('/', '\\').TrimStart('\\'));
            var result  = Directory.GetDirectories(JexusServer.IsRunningOnMono() ? path : winPath, "*", SearchOption.AllDirectories)
                          .Select(folder => JexusServer.IsRunningOnMono() ? folder.Substring(path.Length) : folder.Substring(winPath.Length).Replace('\\', '/'));

            return(result);
        }
Example #2
0
        public bool GetStop()
        {
            var onLinux = JexusServer.IsRunningOnMono() && PlatformSupport.Platform != PlatformType.Windows;
            var process = Process.Start(onLinux ? "jws" : "jws.exe", "stop");

            process.WaitForExit();
            return(true);
        }
Example #3
0
        public bool GetStart(string name)
        {
            var onLinux = JexusServer.IsRunningOnMono() && PlatformSupport.Platform != PlatformType.Windows;
            var process = Process.Start(onLinux ? "jws" : "jws.exe", string.Format("start {0}", name));

            process.WaitForExit();
            return(true);
        }
Example #4
0
        public bool GetState()
        {
            var onLinux = JexusServer.IsRunningOnMono() && PlatformSupport.Platform != PlatformType.Windows;
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName  = onLinux ? "jws" : "jws.exe",
                    Arguments = "status",
                    RedirectStandardOutput = true,
                    UseShellExecute        = false
                }
            };

            process.Start();
            process.WaitForExit();
            var content = process.StandardOutput.ReadToEnd();

            return(content.Contains("running"));
        }
Example #5
0
 public void Put(SortedDictionary <string, List <string> > variables)
 {
     JexusServer.ServerVariables = variables;
     JexusServer.Save();
 }