Mercurial > hg > octave-nkf
diff libinterp/corefcn/sysdep.cc @ 19979:904912f18357
make open_with_system_app a built-in function
* sysdep.cc (Fopen_with_system_app): Rename from
F__w32_shell_execute__. Make it work for Unixy systems.
* open.m (open_with_system_app): Delete subfunction.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 Feb 2015 17:33:59 -0500 |
parents | 4197fc428c7d |
children | 1c9ed5b4c73d |
line wrap: on
line diff
--- a/libinterp/corefcn/sysdep.cc +++ b/libinterp/corefcn/sysdep.cc @@ -178,36 +178,49 @@ command_editor::prefer_env_winsize (true); } + +static bool +w32_shell_execute (const std::string& file) +{ +} #endif -DEFUN (__w32_shell_execute__, args, , +DEFUN (open_with_system_app, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} __w32_shell_execute__ (@var{file})\n\ Undocumented internal function.\n\ @end deftypefn") { - bool retval = false; + octave_value retval; -#if defined (__WIN32__) && ! defined (_POSIX_VERSION) if (args.length () == 1) { std::string file = args(0).string_value (); if (! error_state) { - HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0, SW_SHOWNORMAL); +#if defined (__WIN32__) && ! defined (_POSIX_VERSION) + HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0, + SW_SHOWNORMAL); // ShellExecute returns a value greater than 32 if successful. retval = (reinterpret_cast<ptrdiff_t> (status) > 32); +#else + octave_value_list tmp + = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null", + false, "async"), + 1); + + retval = (tmp(0).double_value () == 0); +#endif } else - error ("__w32_shell_execute__: expecting argument to be a file name"); + error ("open_with_system_app: expecting argument to be a file name"); } else print_usage (); -#endif - return octave_value (retval); + return retval; } #if defined (__MINGW32__)