Index: trunk/src/board.c =================================================================== --- trunk/src/board.c (revision 11511) +++ trunk/src/board.c (revision 11512) @@ -158,7 +158,6 @@ { /* copy default settings */ pcb_layer_colors_from_conf(pcb); - return 0; } Index: trunk/src/conf_core.c =================================================================== --- trunk/src/conf_core.c (revision 11511) +++ trunk/src/conf_core.c (revision 11512) @@ -32,7 +32,7 @@ return homedir; } -static void conf_ro(const char *path) +void pcb_conf_ro(const char *path) { conf_native_t *n = conf_get_field(path); if (n != NULL) { @@ -49,11 +49,11 @@ conf_clamp(CFT_COORD, conf_core.design.max_width, PCB_MIN_SIZE, PCB_MAX_COORD); conf_clamp(CFT_COORD, conf_core.design.max_height, PCB_MIN_SIZE, PCB_MAX_COORD); conf_force_set_bool(conf_core.rc.have_regex, 1); - conf_ro("rc/have_regex"); + pcb_conf_ro("rc/have_regex"); - conf_force_set_str(conf_core.rc.path.prefix, PCB_PREFIX); conf_ro("rc/path/prefix"); - conf_force_set_str(conf_core.rc.path.lib, PCBLIBDIR); conf_ro("rc/path/lib"); - conf_force_set_str(conf_core.rc.path.bin, BINDIR); conf_ro("rc/path/bin"); - conf_force_set_str(conf_core.rc.path.share, PCBSHAREDIR); conf_ro("rc/path/share"); - conf_force_set_str(conf_core.rc.path.home, get_homedir()); conf_ro("rc/path/home"); + conf_force_set_str(conf_core.rc.path.prefix, PCB_PREFIX); pcb_conf_ro("rc/path/prefix"); + conf_force_set_str(conf_core.rc.path.lib, PCBLIBDIR); pcb_conf_ro("rc/path/lib"); + conf_force_set_str(conf_core.rc.path.bin, BINDIR); pcb_conf_ro("rc/path/bin"); + conf_force_set_str(conf_core.rc.path.share, PCBSHAREDIR); pcb_conf_ro("rc/path/share"); + conf_force_set_str(conf_core.rc.path.home, get_homedir()); pcb_conf_ro("rc/path/home"); } Index: trunk/src/conf_core.h =================================================================== --- trunk/src/conf_core.h (revision 11511) +++ trunk/src/conf_core.h (revision 11512) @@ -124,6 +124,8 @@ CFT_STRING home; /* user's home dir, determined run-time */ CFT_STRING exec_prefix; /* exec prefix path (extracted from argv[0]) */ + + CFT_STRING design; /* directory path of the current design, or if the current design doesn't have a file name yet */ } path; } rc; @@ -222,4 +224,5 @@ extern conf_core_t conf_core; void conf_core_init(); void conf_core_postproc(); +void pcb_conf_ro(const char *path); #endif Index: trunk/src/file_act.c =================================================================== --- trunk/src/file_act.c (revision 11511) +++ trunk/src/file_act.c (revision 11512) @@ -192,6 +192,7 @@ pcb_board_remove(PCB); PCB = pcb_board_new(1); pcb_board_new_postproc(PCB, 1); + pcb_set_design_dir(NULL); /* setup the new name and reset some values to default */ free(PCB->Name); Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 11511) +++ trunk/src/plug_io.c (revision 11512) @@ -103,6 +103,30 @@ } } +void pcb_set_design_dir(const char *fn) +{ + char *end, *rlp = NULL; + + if (fn != NULL) + rlp = pcb_lrealpath(fn); + + if (conf_core.rc.path.design != NULL) + free(*((CFT_STRING *)(&conf_core.rc.path.design))); + + if (rlp == NULL) { + conf_force_set_str(conf_core.rc.path.design, pcb_strdup("")); + pcb_conf_ro("rc/path/design"); + return; + } + + end = strrchr(rlp, PCB_DIR_SEPARATOR_C); + if (end != NULL) + *end = '\0'; + + conf_force_set_str(conf_core.rc.path.design, rlp); + pcb_conf_ro("rc/path/design"); +} + int pcb_parse_pcb(pcb_board_t *Ptr, const char *Filename, const char *fmt, int load_settings, int ignore_missing) { int res = -1, len, n; @@ -179,6 +203,9 @@ if ((res == 0) && (load_settings)) conf_load_project(NULL, Filename); + if (res == 0) + pcb_set_design_dir(Filename); + if (load_settings) pcb_event(PCB_EVENT_LOAD_POST, "si", Filename, res); @@ -362,6 +389,9 @@ if ((res == 0) && (newfmt)) PCB->Data->loader = p; + if (res == 0) + pcb_set_design_dir(new_filename); + plug_io_err(res, "write pcb", NULL); return res; } Index: trunk/src/plug_io.h =================================================================== --- trunk/src/plug_io.h (revision 11511) +++ trunk/src/plug_io.h (revision 11512) @@ -131,6 +131,7 @@ void pcb_set_some_route_style(); int pcb_write_pcb_file(const char *Filename, pcb_bool thePcb, const char *fmt, pcb_bool emergency, pcb_bool elem_only); int pcb_write_pipe(const char *, pcb_bool, const char *fmt, pcb_bool elem_only); +void pcb_set_design_dir(const char *fn); #ifndef HAS_ATEXIT void pcb_tmp_data_save(void);