Mercurial > hg > octave-nkf
changeset 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 | 034bcac0b61c |
children | a941a65c7cb8 |
files | libinterp/corefcn/sysdep.cc scripts/miscellaneous/open.m |
diffstat | 2 files changed, 20 insertions(+), 18 deletions(-) [+] |
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__)
--- a/scripts/miscellaneous/open.m +++ b/scripts/miscellaneous/open.m @@ -76,14 +76,3 @@ %!error open %!error open (1) %!error output = open (1) - -function open_with_system_app (file) - - if (ispc ()) - __w32_shell_execute__ (file); - else - ## FIXME: might not be xdg-open... - system (sprintf ("xdg-open %s 2> /dev/null", file), false, "async"); - endif - -endfunction