26 #if defined (HAVE_CONFIG_H)
70 static bool Vconfirm_recursive_rmdir =
true;
103 int nargin = args.length ();
111 retval =
octave_value (sys::env::get_current_directory ());
115 std::string
dirname = args(0).xstring_value (
"cd: DIR must be a string");
120 else if (nargout == 0)
122 std::string home_dir = sys::env::get_home_directory ();
124 if (! home_dir.empty ())
125 interp.chdir (home_dir);
140 return ovl (sys::env::get_current_directory ());
143 DEFUN (readdir, args, ,
157 if (args.length () != 1)
160 std::string
dirname = args(0).xstring_value (
"readdir: DIR must be a string");
183 DEFUN (__mkdir__, args, ,
192 int nargin = args.length ();
194 if (nargin < 1 || nargin > 2)
201 std::string parent = args(0).xstring_value (
"mkdir: PARENT must be a string");
202 std::string dir = args(1).xstring_value (
"mkdir: DIR must be a string");
206 else if (nargin == 1)
207 dirname = args(0).xstring_value (
"mkdir: DIR must be a string");
214 return ovl (
true,
"directory exists",
"mkdir");
223 return ovl (
false, msg,
"mkdir");
225 return ovl (
true,
"",
"");
247 int nargin = args.length ();
249 if (nargin < 1 || nargin > 2)
252 std::string
dirname = args(0).xstring_value (
"rmdir: DIR must be a string");
263 if (args(1).string_value () !=
"s")
264 error (R
"(rmdir: second argument must be "s" for recursive removal)");
268 if (interp.interactive ()
270 && Vconfirm_recursive_rmdir)
274 std::string prompt =
"remove entire contents of " + fulldir +
"? ";
296 error (
"rmdir: operation failed: %s", msg.c_str ());
301 retval =
ovl (
false, msg,
"rmdir");
303 retval =
ovl (
true,
"",
"");
321 if (args.length () != 2)
324 std::string from = args(0).xstring_value (
"link: OLD must be a string");
325 std::string to = args(1).xstring_value (
"link: NEW must be a string");
338 error (
"link: operation failed: %s", msg.c_str ());
343 retval =
ovl (-1.0, msg);
345 retval =
ovl (0.0,
"");
363 if (args.length () != 2)
366 std::string from = args(0).xstring_value (
"symlink: OLD must be a string");
367 std::string to = args(1).xstring_value (
"symlink: NEW must be a string");
380 error (
"symlink: operation failed: %s", msg.c_str ());
385 retval =
ovl (-1.0, msg);
387 retval =
ovl (0.0,
"");
406 if (args.length () != 1)
409 std::string
symlink = args(0).xstring_value (
"readlink: SYMLINK must be a string");
413 std::string result, msg;
418 return ovl (
"", -1.0, msg);
420 return ovl (result, status,
"");
435 if (args.length () != 2)
438 std::string from = args(0).xstring_value (
"rename: OLD must be a string");
439 std::string to = args(1).xstring_value (
"rename: NEW must be a string");
458 error (
"rename: operation failed: %s", msg.c_str ());
463 retval =
ovl (-1.0, msg);
465 retval =
ovl (0.0,
"");
526 if (args.length () != 1)
530 = args(0).xstring_vector_value (
"glob: PATTERN must be a string");
578 DEFUN (__wglob__, args, ,
634 if (args.length () == 0)
691 DEFUN (__fnmatch__, args, ,
709 if (args.length () != 2)
720 DEFUN (filesep, args, ,
733 int nargin = args.length ();
744 std::string s = args(0).xstring_value (
"filesep: argument must be a string");
746 error (R
"(filesep: argument must be "all")");
754 DEFUN (pathsep, args, ,
761 if (args.length () > 0)
767 DEFUN (confirm_recursive_rmdir, args, nargout,
782 "confirm_recursive_rmdir");
785 OCTAVE_END_NAMESPACE(
octave)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
octave_value_list Freadlink(const octave_value_list &=octave_value_list(), int=0)
octave_value_list Frename(octave::interpreter &, const octave_value_list &=octave_value_list(), int=0)
octave_value_list Frmdir(octave::interpreter &, const octave_value_list &=octave_value_list(), int=0)
octave_value_list Flink(const octave_value_list &=octave_value_list(), int=0)
octave_value_list Fsymlink(const octave_value_list &=octave_value_list(), int=0)
static bool forced_interactive()
static std::string path_sep_str()
Provides threadsafe access to octave.
void file_renamed(bool load_new)
void file_remove(const std::string &old_name, const std::string &new_name)
string_vector glob() const
bool match(const std::string &str) const
string_vector & sort(bool make_uniq=false)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
#define DEFUNX(name, fname, args_name, nargout_name, doc)
Macro to define a builtin function with certain internal name.
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
void() error(const char *fmt,...)
std::string dir_sep_str()
std::string dir_sep_chars()
std::string dirname(const std::string &path)
bool dir_exists(const std::string &dirname)
int chdir(const std::string &path_arg)
bool get_dirlist(const std::string &dirname, string_vector &dirlist, std::string &msg)
std::string tilde_expand(const std::string &name)
int symlink(const std::string &old_name, const std::string &new_name)
int mkdir(const std::string &nm, mode_t md)
int readlink(const std::string &path, std::string &result)
int link(const std::string &old_name, const std::string &new_name)
int recursive_rmdir(const std::string &name)
int rename(const std::string &from, const std::string &to)
int rmdir(const std::string &name)
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
string_vector windows_glob(const string_vector &pat)
string_vector glob(const string_vector &pat)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
DEFMETHODX("quad", Fquad, interp, args,, doc:)