26#if defined (HAVE_CONFIG_H)
102 int nargin = args.length ();
110 retval =
octave_value (sys::env::get_current_directory ());
114 std::string
dirname = args(0).xstring_value (
"cd: DIR must be a string");
119 else if (nargout == 0)
121 std::string home_dir = sys::env::get_home_directory ();
123 if (! home_dir.empty ())
124 interp.chdir (home_dir);
140 return ovl (sys::env::get_current_directory ());
143DEFUN (readdir, args, ,
157 if (args.length () != 1)
160 std::string
dirname = args(0).xstring_value (
"readdir: DIR must be a string");
183DEFUN (__mkdir__, args, ,
190 int nargin = args.length ();
192 if (nargin < 1 || nargin > 2)
199 std::string parent = args(0).xstring_value (
"mkdir: PARENT must be a string");
200 std::string dir = args(1).xstring_value (
"mkdir: DIR must be a string");
204 else if (nargin == 1)
205 dirname = args(0).xstring_value (
"mkdir: DIR must be a string");
211 if (fs && fs.is_dir ())
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 ()
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");
538DEFUN (__wglob__, args, ,
594 if (args.length () == 0)
636DEFUN (__fnmatch__, args, ,
654 if (args.length () != 2)
665DEFUN (filesep, args, ,
678 int nargin = args.length ();
689 std::string s = args(0).xstring_value (
"filesep: argument must be a string");
691 error (R
"(filesep: argument must be "all")");
699DEFUN (pathsep, args, ,
706 if (args.length () > 0)
709 return ovl (directory_path::path_sep_str ());
712DEFUN (confirm_recursive_rmdir, args, nargout,
727 "confirm_recursive_rmdir");
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
static bool forced_interactive(void)
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(void) const
bool match(const std::string &str) const
string_vector & sort(bool make_uniq=false)
static octave_idx_type link(octave_idx_type s, octave_idx_type t, octave_idx_type *pp)
OCTINTERP_API void print_usage(void)
#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.
OCTAVE_EXPORT octave_value_list Frename(octave::interpreter &interp, const octave_value_list &args, int nargout)
OCTAVE_EXPORT octave_value_list Frmdir(octave::interpreter &interp, const octave_value_list &args, int nargout)
OCTAVE_EXPORT octave_value_list Fsymlink(const octave_value_list &args, int nargout)
static OCTAVE_NAMESPACE_BEGIN bool Vconfirm_recursive_rmdir
OCTAVE_EXPORT octave_value_list Flink(const octave_value_list &args, int nargout)
OCTAVE_EXPORT octave_value_list Freadlink(const octave_value_list &args, int)
void error(const char *fmt,...)
std::string dirname(const std::string &path)
std::string tilde_expand(const std::string &name)
std::string dir_sep_str(void)
string_vector glob(const string_vector &pat)
int readlink(const std::string &path, std::string &result)
int rename(const std::string &from, const std::string &to)
int mkdir(const std::string &nm, mode_t md)
int symlink(const std::string &old_name, const std::string &new_name)
int rmdir(const std::string &name)
int recursive_rmdir(const std::string &name)
string_vector windows_glob(const string_vector &pat)
bool get_dirlist(const std::string &dirname, string_vector &dirlist, std::string &msg)
int chdir(const std::string &path_arg)
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:)
static std::string dir_sep_chars
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)