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>
105 if (err && errno == 29) {
129 int i = fscanf(f->
file(),
"%s",
buf);
132 return double(strlen(
buf));
147 FILE* fw = f->
file();
151 return double(strlen(
buf));
159 return double(f->
mktemp());
164 return double(f->
unlink());
169 return double(f->
eof());
190 return (
const char**) ps;
196 *ps = (
char*) f->
dir();
197 return (
const char**) ps;
208 return double(f->file_chooser_popup());
211 char *
type, *
banner, *filter, *bopen, *cancel;
213 const char* path =
".";
231 f->file_chooser_style(
type, path,
banner, filter, bopen, cancel);
247 n =
long(
chkarg(1, 1., 2.e18));
270 base = int(
chkarg(2, 0., 2.));
322 void OcFile::binary_mode() {
323 if (
file() && !binary_) {
324 if (ftell(
file()) != 0) {
326 ":can switch to dos binary file mode only at beginning of file.\n\
327 Use File.seek(0) after opening or use a binary style read/write as first\n\
330 #if defined(__MWERKS__)
336 setmode(fileno(
file()), O_BINARY);
350 #if defined(FILE_OPEN_RETRY) && FILE_OPEN_RETRY > 0
352 for (
i = 0; !
file_ &&
i < FILE_OPEN_RETRY; ++
i) {
377 return ungetc(
c,
file()) == EOF;
400 const char* cancel) {
404 Style* style =
new Style(Session::instance()->style());
409 style->attribute(
"caption",
banner);
415 style->attribute(
"filter",
"true");
416 style->attribute(
"filterPattern", filter);
421 style->attribute(
"open", bopen);
423 }
else if (
type[0] ==
'w') {
424 style->attribute(
"open",
"Save");
428 style->attribute(
"cancel", cancel);
434 style->attribute(
"caption",
"File write");
437 style->attribute(
"caption",
"File append");
440 style->attribute(
"caption",
"File read");
443 style->attribute(
"caption",
"Directory open");
446 style->attribute(
"caption",
"File name only");
461 style->attribute(
"choose_directory",
"on");
467 fc_ = DialogKit::instance()->file_chooser(path, style);
489 hoc_execerror(
"First call to file_chooser must at least specify r or w", 0);
492 Display* d = Session::instance()->default_display();
504 while (
fc_->post_at_aligned(x, y, ax, ay)) {
508 open(
fc_->selected()->string(),
"w");
514 open(
fc_->selected()->string(),
"a");
521 open(
fc_->selected()->string(),
"r");
548 if (_stat(path.c_str(), &
info) != 0) {
551 return (
info.st_mode & _S_IFDIR) != 0;
554 if (stat(path.c_str(), &
info) != 0) {
557 return (
info.st_mode & S_IFDIR) != 0;
563 int ret = _mkdir(path.c_str());
566 int ret = mkdir(path.c_str(), mode);
575 int pos = path.find_last_of(
'/');
576 if (pos == std::string::npos)
578 pos = path.find_last_of(
'\\');
579 if (pos == std::string::npos)
587 return 0 == _mkdir(path.c_str());
589 return 0 == mkdir(path.c_str(), mode);
void set_name(const char *s)
void print(const char *s)
bool file_chooser_popup()
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)
bool open(const char *filename, const char *type)
virtual void unref() const
const char * string() const
double chkarg(int, double low, double high)
void hoc_execerror(const char *, const char *)
FILE * hoc_obj_file_arg(int i)
void hoc_assign_str(char **cpp, const char *buf)
const char * expand_env_var(const char *s)
char ** hoc_temp_charptr(void)
void hoc_sprint1(char **ppbuf, int argn)
Symbol * hoc_lookup(const char *)
double * hoc_pgetarg(int narg)
char ** hoc_pgargstr(int narg)
#define TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE(name, sym, v)
char * fgets_unlimited(HocStr *s, NrnFILEWrap *f)
Object ** hoc_objgetarg(int)
int const size_t const size_t n
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
static double f_printf(void *v)
static double f_scanstr(void *v)
static const char ** f_get_name(void *v)
static double f_chooser(void *v)
static double f_scanvar(void *v)
static double f_is_open(void *v)
static double f_unlink(void *v)
bool makePath(const std::string &path)
double(* nrnpy_object_to_double_)(Object *)
static double f_vwrite(void *v)
static double f_close(void *v)
static Symbol * file_class_sym_
char * ivoc_get_temp_file()
static double f_ropen(void *v)
bool isDirExist(const std::string &path)
static double f_seek(void *v)
static double f_wopen(void *v)
static double f_eof(void *v)
static void * f_cons(Object *)
static double f_aopen(void *v)
static int ivoc_unlink(const char *)
static double f_tell(void *v)
static const char ** f_dir(void *v)
static double f_flush(void *v)
static void f_destruct(void *v)
static double f_vread(void *v)
static double f_gets(void *v)
static Member_ret_str_func f_retstr_members[]
static double f_mktemp(void *v)
#define BinaryMode(ocfile)
check_obj_type(o, "SectionList")
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...
bool ok_to_write(const String &, Window *w=NULL)
bool ok_to_read(const String &, Window *w=NULL)