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);
139 return ovl (sys::env::get_current_directory ());
142 DEFUN (readdir, args, ,
156 if (args.length () != 1)
159 std::string
dirname = args(0).xstring_value (
"readdir: DIR must be a string");
182 DEFUN (__mkdir__, args, ,
191 int nargin = args.length ();
193 if (nargin < 1 || nargin > 2)
200 std::string parent = args(0).xstring_value (
"mkdir: PARENT must be a string");
201 std::string dir = args(1).xstring_value (
"mkdir: DIR must be a string");
205 else if (nargin == 1)
206 dirname = args(0).xstring_value (
"mkdir: DIR must be a string");
212 if (fs && fs.is_dir ())
215 return ovl (
true,
"directory exists",
"mkdir");
224 return ovl (
false, msg,
"mkdir");
226 return ovl (
true,
"",
"");
248 int nargin = args.length ();
250 if (nargin < 1 || nargin > 2)
253 std::string
dirname = args(0).xstring_value (
"rmdir: DIR must be a string");
264 if (args(1).string_value () !=
"s")
265 error (R
"(rmdir: second argument must be "s" for recursive removal)");
269 if (interp.interactive ()
275 std::string prompt =
"remove entire contents of " + fulldir +
"? ";
297 error (
"rmdir: operation failed: %s", msg.c_str ());
302 retval =
ovl (
false, msg,
"rmdir");
304 retval =
ovl (
true,
"",
"");
322 if (args.length () != 2)
325 std::string from = args(0).xstring_value (
"link: OLD must be a string");
326 std::string to = args(1).xstring_value (
"link: NEW must be a string");
339 error (
"link: operation failed: %s", msg.c_str ());
344 retval =
ovl (-1.0, msg);
346 retval =
ovl (0.0,
"");
364 if (args.length () != 2)
367 std::string from = args(0).xstring_value (
"symlink: OLD must be a string");
368 std::string to = args(1).xstring_value (
"symlink: NEW must be a string");
381 error (
"symlink: operation failed: %s", msg.c_str ());
386 retval =
ovl (-1.0, msg);
388 retval =
ovl (0.0,
"");
407 if (args.length () != 1)
410 std::string
symlink = args(0).xstring_value (
"readlink: SYMLINK must be a string");
414 std::string result, msg;
419 return ovl (
"", -1.0, msg);
421 return ovl (result, status,
"");
436 if (args.length () != 2)
439 std::string from = args(0).xstring_value (
"rename: OLD must be a string");
440 std::string to = args(1).xstring_value (
"rename: NEW must be a string");
459 error (
"rename: operation failed: %s", msg.c_str ());
464 retval =
ovl (-1.0, msg);
466 retval =
ovl (0.0,
"");
527 if (args.length () != 1)
531 = args(0).xstring_vector_value (
"glob: PATTERN must be a string");
579 DEFUN (__wglob__, args, ,
635 if (args.length () == 0)
692 DEFUN (__fnmatch__, args, ,
710 if (args.length () != 2)
721 DEFUN (filesep, args, ,
734 int nargin = args.length ();
745 std::string s = args(0).xstring_value (
"filesep: argument must be a string");
747 error (R
"(filesep: argument must be "all")");
755 DEFUN (pathsep, args, ,
762 if (args.length () > 0)
768 DEFUN (confirm_recursive_rmdir, args, nargout,
783 "confirm_recursive_rmdir");
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
static bool forced_interactive(void)
static std::string path_sep_str(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)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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.
static bool Vconfirm_recursive_rmdir
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)
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,...)
int rename(const std::string &from, const std::string &to)
int symlink(const std::string &old_name, const std::string &new_name)
int readlink(const std::string &path, std::string &result)
int rmdir(const std::string &name)
std::string dirname(const std::string &path)
int link(const std::string &old_name, const std::string &new_name)
std::string dir_sep_str(void)
int recursive_rmdir(const std::string &name)
int mkdir(const std::string &nm, mode_t md)
std::string tilde_expand(const std::string &name)
int chdir(const std::string &path_arg)
bool get_dirlist(const std::string &dirname, string_vector &dirlist, std::string &msg)
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:)
static std::string dir_sep_chars
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)