1 #include <../../nrnconf.h> 8 #if MAC || defined(HAVE_UNISTD_H) 22 #include <IV-look/dialogs.h> 23 #include <InterViews/session.h> 24 #include <InterViews/display.h> 25 #include <InterViews/style.h> 126 int i = fscanf(f->
file(),
"%s",
buf);
129 return double(strlen(buf));
144 FILE* fw = f->
file();
148 return double(strlen(buf));
156 return double(f->
mktemp());
161 return double(f->
unlink());
166 return double(f->
eof());
187 return (
const char**)ps;
193 *ps = (
char*)f->
dir();
194 return (
const char**)ps;
205 return double(f->file_chooser_popup());
208 char *
type, *
banner, *filter, *bopen, *cancel;
209 banner=filter=bopen=cancel=
NULL;
210 const char *path=
".";
228 f->file_chooser_style(type, path, banner, filter, bopen, cancel);
246 return (
double)fwrite(x,
sizeof(
double),n,f->
file());
255 return (
double)fread(x,
sizeof(
double),n,f->
file());
270 return (
double)fseek(f->
file(),
n,base);
277 return (
double)ftell(f->
file());
339 void OcFile::binary_mode() {
340 if (
file() && !binary_) {
341 if (ftell(
file()) != 0) {
343 ":can switch to dos binary file mode only at beginning of file.\n\ 344 Use File.seek(0) after opening or use a binary style read/write as first\n\ 347 #if defined(__MWERKS__) 349 mode_[1] =
'b'; mode_[2] =
'\0';
352 setmode(fileno(
file()), O_BINARY);
366 #if defined(FILE_OPEN_RETRY) && FILE_OPEN_RETRY > 0 368 for (i=0; !
file_ && i < FILE_OPEN_RETRY; ++
i) {
393 return ungetc(c,
file()) == EOF;
412 const char* filter,
const char* bopen,
const char* cancel)
417 Style* style =
new Style(Session::instance()->style());
422 style->attribute(
"caption", banner);
428 style->attribute(
"filter",
"true");
429 style->attribute(
"filterPattern", filter);
434 style->attribute(
"open", bopen);
436 }
else if (type[0] ==
'w') {
437 style->attribute(
"open",
"Save");
441 style->attribute(
"cancel", cancel);
444 if (nocap)
switch( type[0] ) {
446 style->attribute(
"caption",
"File write");
449 style->attribute(
"caption",
"File append");
452 style->attribute(
"caption",
"File read");
455 style->attribute(
"caption",
"Directory open");
458 style->attribute(
"caption",
"File name only");
473 style->attribute(
"choose_directory",
"on");
479 fc_ = DialogKit::instance()->file_chooser(path, style);
501 hoc_execerror(
"First call to file_chooser must at least specify r or w", 0);
504 Display* d = Session::instance()->default_display();
516 while (
fc_->post_at_aligned(x, y, ax, ay)) {
520 open(
fc_->selected()->string(),
"w");
526 open(
fc_->selected()->string(),
"a");
533 open(
fc_->selected()->string(),
"r");
561 if (_stat(path.c_str(), &
info) != 0)
565 return (info.st_mode & _S_IFDIR) != 0;
568 if (stat(path.c_str(), &
info) != 0)
572 return (info.st_mode & S_IFDIR) != 0;
579 int ret = _mkdir(path.c_str());
582 int ret = mkdir(path.c_str(), mode);
592 int pos = path.find_last_of(
'/');
593 if (pos == std::string::npos)
595 pos = path.find_last_of(
'\\');
596 if (pos == std::string::npos)
599 if (!
makePath( path.substr(0, pos) ))
604 return 0 == _mkdir(path.c_str());
606 return 0 == mkdir(path.c_str(), mode);
static double f_tell(void *v)
static double f_scanvar(void *v)
bool makePath(const std::string &path)
bool ok_to_write(const String &, Window *w=NULL)
static double f_vwrite(void *v)
void file_chooser_style(const char *type, const char *path, const char *banner=NULL, const char *filter=NULL, const char *accept=NULL, const char *cancel=NULL)
static double f_wopen(void *v)
static double f_is_open(void *v)
static double f_mktemp(void *v)
Symbol * hoc_lookup(const char *)
static double f_aopen(void *v)
static Member_ret_str_func f_retstr_members[]
#define TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE(name, sym, v)
const char * expand_env_var(const char *s)
check_obj_type(o, "SectionList")
char * ivoc_get_temp_file()
bool file_chooser_popup()
char ** hoc_pgargstr(int narg)
#define BinaryMode(ocfile)
void print(const char *s)
static double f_eof(void *v)
double * hoc_pgetarg(int narg)
const char * string() const
static double f_seek(void *v)
static void * f_cons(Object *)
bool isDirExist(const std::string &path)
void hoc_assign_str(char **cpp, const char *buf)
static double f_unlink(void *v)
void hoc_sprint1(char **ppbuf, int argn)
int const size_t const size_t n
static double f_gets(void *v)
bool nrn_spec_dialog_pos(Coord &x, Coord &y)
true if Style 'dialog_spec_position: on' and fills x,y with dialog_left_position and dialog_bottom_po...
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
void hoc_execerror(const char *, const char *)
static double f_chooser(void *v)
static double f_ropen(void *v)
char * fgets_unlimited(HocStr *s, NrnFILEWrap *f)
virtual void unref() const
static double f_vread(void *v)
static void f_destruct(void *v)
bool ok_to_read(const String &, Window *w=NULL)
static double f_close(void *v)
static double f_printf(void *v)
bool open(const char *filename, const char *type)
FILE * hoc_obj_file_arg(int i)
static const char ** f_get_name(void *v)
static const char ** f_dir(void *v)
static double f_scanstr(void *v)
void set_name(const char *s)
double(* nrnpy_object_to_double_)(Object *)
static int ivoc_unlink(const char *)
char ** hoc_temp_charptr(void)
static double f_flush(void *v)
Object ** hoc_objgetarg(int)
double chkarg(int, double low, double high)
static Symbol * file_class_sym_