Mercurial > hg > octave-nkf
diff libinterp/corefcn/sysdep.cc @ 19463:030d56f67363
implement the open function
* open.m: New function.
* system.txi: Document it.
* __unimplemented__.m (missing_functions): Remove open from the list.
* scripts/miscellaneous/module.mk (miscellaneous_FCN_FILES):
Include open.m in the list.
* sysdep.cc (F__w32_shell_execute__): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 15 Oct 2014 22:35:59 -0400 |
parents | efccb2a65b9a |
children | 912158cf524d |
line wrap: on
line diff
--- a/libinterp/corefcn/sysdep.cc +++ b/libinterp/corefcn/sysdep.cc @@ -106,6 +106,7 @@ #define WIN32_LEAN_AND_MEAN #include <tlhelp32.h> +#include <windows.h> static void w32_set_octave_home (void) @@ -179,6 +180,36 @@ } #endif +DEFUN (__w32_shell_execute__, args, , + "-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} __w32_shell_execute__ (@var{file})\n\ +Undocumented internal function.\n\ +@end deftypefn") +{ + bool retval = false; + +#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); + + // ShellExecute returns a value greater than 32 if successful. + retval = (reinterpret_cast<ptrdiff_t> (status) > 32); + } + else + error ("__w32_shell_execute__: expecting argument to be a file name"); + } + else + print_usage (); +#endif + + return octave_value (retval); +} + #if defined (__MINGW32__) static void MINGW_init (void)