public ProgramRunType GetProgramRunType(string cmd) { NixPath path = new NixPath(cmd); ProgramRunType result = new ProgramRunType(); string pathTo = RootDrive.GetPathTo(RootDrive.FollowLinks(path)); Debug.Log("GPRT: " + path.ToString() + " | " + pathTo); using (StreamReader reader = new StreamReader(pathTo)) { string firstLine = reader.ReadLine(); if (firstLine.Length > 2) { if (firstLine[0] == '#' && firstLine[1] == '!') { Debug.Log("Has a shebang! " + firstLine); result.BinaryCode = false; result.Shebang = firstLine.Substring(2); } // Definitly not a good way of determining if it is a DLL // Need to look further into the file to determine if it really is. else if (firstLine[0] == 'M' && firstLine[1] == 'Z') { Debug.Log("Possibly a DLL"); result.BinaryCode = true; } } } return(result); }
public FindCommandResult FindCommand(string cmd) { Debug.Log("Searching for: " + cmd); FindCommandResult result = new FindCommandResult(); string [] envPathSplit = BaseSession.GetEnvValue("PATH").Split(new char[] { ':' }); for (int i = 0; i < envPathSplit.Length; i++) { NixPath path = new NixPath(envPathSplit[i]); path.AppendPath(cmd); if (RootDrive.IsFile(path)) { result.Path = path.ToString(); result.Builtin = false; result.Found = true; return(result); } } if (BinPrograms.ContainsKey(cmd)) { result.Path = cmd; result.Builtin = true; result.Found = true; return(result); } result.Found = false; return(result); }