## Copyright (C) 2010 Soren Hauberg ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} winopen (@var{filename}) ## Open a file in the users preferred application. ## ## The function asks the operating system to open the given input file in the ## associated application. For example, ## ## @example ## winopen ("my_text_file.txt"); ## @end example ## ## @noindent ## opens the file @t{"my_text_file.txt"} in the default text editor. ## ## The function can also be used to open directories in the default file manager. ## For example, ## ## @example ## winopen (pwd ()); ## @end example ## ## @noindent ## opens the current directory in the default file manager. ## @end deftypefn function winopen (filename) if (nargin == 1 && ischar (filename)) ## Make choice depending in operating system if (ispc ()) cmd = "start \"%s\""; # XXX: is this the correct command? elseif (ismac ()) cmd = "open \"%s\""; # XXX: is this the correct command? elseif (isunix ()) cmd = "xdg-open \"%s\""; else error ("winopen: unsupported operating system"); endif ## Run the actual command [error_occured, output] = system (sprintf (cmd, filename)); if (error_occured) error ("winopen: could not handle file '%s': %s", filename, output); endif else error ("winopen: one string input argument must be supplied"); endif endfunction