[Scummvm-devel] OSystem::displayLogFile()

Willem Jan Palenstijn wjp at usecode.org
Sat Jun 4 15:33:55 CEST 2011


On Sat, Jun 04, 2011 at 11:14:55AM +0200, Max Horn wrote:
> 
> Am 04.06.2011 um 03:33 schrieb Johannes Schickel:
> 
> >> Couldn't you do something along the lines of:
> >> 
> >> xterm -e less $PATH_TO_SCUMMVM_LOG
> >> 
> >> I'm assuming both commands are available (by default) on all *NIX distros.
> >> I was going to recommend a GUI message + xclip, but xclip isn't installed
> >> by default :P
> >> 
> > 
> > xterm is not installed on the distribution (Arch) on my desktop per default. 
> > At least I can't remember deleting it, so I guess it wasn't installed when 
> > installing Xorg for example.
> 
> Well, do you have xdg-open? Then that is used anyway.
> 
> You have neither of the two? WEll, then you are not worse off than now :) And
> we could still install a third fallback.
> 
> *If* any Linux devs, or Windows devs, show any interest in implementing this
> feature, anyway :)

I committed a second attempt at this just now.

The first attempt used system but that handled a missing xdg-open less than
gracefully, outputting errors about a missing xdg-open in the terminal.
Handling this properly and also avoiding any quoting issues would take more
work than simply calling fork and execlp manually, so that's what I did.


Fuzzie also reminded me on IRC that we may want to rename the log file to have
a .txt extension to make file type detection safer. It currently works fine for
me on XFCE in Gentoo and Gnome in Fedora (12) with the .log extension, though.


Testing on as many unix-like platforms as possible would be appreciated.



For archival purposes (and if on any systems the fork/execlp variant doesn't
work, but system would) here's the first variant that I didn't commit:

	if (_logFilePath.contains('\'')) {
		warning("Cannot currently open viewer if logFilePath contains single quotes");
		return false;
	}

	Common::String cmd;
	cmd = Common::String::format("xdg2-open '%s' || xterm -e less '%s'",
	                             _logFilePath.c_str(), _logFilePath.c_str());

	int res = system(cmd.c_str());
	return res != 0;




-Willem Jan




More information about the Scummvm-devel mailing list