Commit 2df1e3ad authored by Claes Sjofors's avatar Claes Sjofors

Build sequence for copying files from improved

parent f3577204
......@@ -117,7 +117,11 @@ void dcli_save_file_versions( char *fname);
#define DCLI_DIR_SEARCH_END 2
int dcli_search_file( const char *file_name ,
int dcli_search_file( const char *file_name,
char *found_file,
int new_search);
int dcli_search_directory( const char *file_name,
char *found_file,
int new_search);
......@@ -133,6 +137,9 @@ int dcli_parse_filename( const char *filename,
char *type,
int *version);
int dcli_create_directory( char *path);
int dcli_delete_directory( char *path, int force);
/* Functions i module co_dcli_struct */
typedef struct s_element {
......
......@@ -71,6 +71,10 @@
# include <ctype.h>
# include <string.h>
# include <dirent.h>
# include <sys/stat.h>
# include <sys/types.h>
# include <unistd.h>
# include <errno.h>
#endif
#include "pwr.h"
......@@ -87,31 +91,18 @@
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
/*************************************************************************
*
* Name: dcli_search_file
*
* Typ int
*
* Typ Parameter IOGF Beskrivning
/* Search for one or several files.
* The file name can contain wildcard, *.
* Should be called for the first time with new = DCLI_DIR_SEARCH_INIT.
* If more then one file is searched for, the next files are found with
* calls where new = DCLI_DIR_SEARCH_NEXT. When the search is finished,
* one call with DCLI_DIR_SEARCH_END should be made.
* Two parallell searches are not allowed as data is stored internally.
*
* Beskrivning:
* Sker efter en fil.
* Filnamnet kan innehlla wildcard.
* Vid skning av flera filer mha wildcard anropas
* rutinen frsta gngen med new=1 och sedan med new=0.
* Tv skningar med wildcard kan ej pg parallellt efter
* som skvillkor lagras i interna variabler.
*
* Parametrar
* file_name *char I Namn p fil, kan innehlla wildcard.
* found_file *char O Hittad fil.
* new int I 1 vid ej wildcard skning och vid frsta
* wildcardskningsanropet. 0 vid skning
* efter fler filer med samma wildcard.
*
**************************************************************************/
* file_name File name, can contain wildcard.
* found_file Found file.
* new DCLI_DIR_SEARCH_INIT, DCLI_DIR_SEARCH_NEXT or DCLI_DIR_SEARCH_END.
*/
int dcli_search_file( const char *name ,
char *found_file,
......@@ -291,6 +282,119 @@ int dcli_search_file( const char *name ,
return DCLI__SUCCESS;
}
/* Search for one or several directories.
* The file name can contain wildcard, *.
* Should be called for the first time with new = DCLI_DIR_SEARCH_INIT.
* If more then one file is searched for, the next files are found with
* calls where new = DCLI_DIR_SEARCH_NEXT. When the search is finished,
* one call with DCLI_DIR_SEARCH_END should be made.
* Two parallell searches are not allowed as data is stored internally.
*
* file_name File name, can contain wildcard.
* found_file Found file.
* new DCLI_DIR_SEARCH_INIT, DCLI_DIR_SEARCH_NEXT or DCLI_DIR_SEARCH_END.
*/
int dcli_search_directory( const char *name ,
char *found_file,
int new)
{
#if defined OS_POSIX
static DIR *directory;
static char pattern[200];
static char dir[200];
char dev[2], dir2[200], file[80], type[80];
char cwd[200];
int version;
int found;
static int wildcard;
struct dirent *dir_entry;
if ( new == DCLI_DIR_SEARCH_INIT)
{
dcli_parse_filename( name, dev, dir, file, type, &version);
dcli_replace_env( dir, dir2);
if ( dir2[0] != '/')
{
/* Add cwd to the path */
if ( getcwd( cwd, sizeof(cwd)) == NULL)
return DCLI__NOFILE;
strcpy( dir, cwd);
if ( dir[strlen(dir)-1] != '/')
strcat( dir, "/");
strcat( dir, dir2);
}
else
strcpy( dir, dir2);
directory = opendir( dir);
if ( directory == NULL)
return DCLI__NOFILE;
strcpy( pattern, file);
strcat( pattern, type);
if ( strchr( pattern, '*') != 0)
wildcard = 1;
else
wildcard = 0;
// if ( wildcard)
// dcli_toupper( pattern, pattern);
}
if ( new == DCLI_DIR_SEARCH_INIT || new == DCLI_DIR_SEARCH_NEXT)
{
found = 0;
while ( (dir_entry = readdir( directory)) != NULL)
{
struct stat st;
if ( strcmp( dir_entry->d_name, ".") == 0 ||
strcmp( dir_entry->d_name, "..") == 0)
continue;
if ( fstatat( dirfd(directory), dir_entry->d_name, &st, 0) < 0)
continue;
if ( !S_ISDIR(st.st_mode))
continue;
if ( wildcard) {
if ( dcli_wildcard( pattern, dir_entry->d_name) == 0) {
strcpy( found_file, dir);
strcat( found_file, dir_entry->d_name);
found = 1;
}
}
else {
if ( strcmp( pattern, dir_entry->d_name) == 0) {
strcpy( found_file, dir);
strcat( found_file, dir_entry->d_name);
found = 1;
}
}
if ( found)
break;
}
if ( !found)
return DCLI__NOFILE;
else
return DCLI__SUCCESS;
}
if ( new == DCLI_DIR_SEARCH_END) {
if ( directory)
closedir( directory);
}
return DCLI__SUCCESS;
#else
return 0;
#endif
return DCLI__SUCCESS;
}
/*************************************************************************
*
......@@ -541,3 +645,31 @@ int dcli_parse_filename( const char *filename,
#endif
}
int dcli_create_directory( char *path)
{
pwr_tFileName fname;
dcli_translate_filename( fname, path);
if ( mkdir( fname, 0777) != 0)
return 0;
return 1;
}
int dcli_delete_directory( char *path, int force)
{
pwr_tFileName fname;
dcli_translate_filename( fname, path);
if ( rmdir( fname) != 0) {
if ( !force)
return 0;
if ( force && errno == ENOTEMPTY) {
pwr_tCmd cmd;
sprintf( cmd, "rm -r %s", path);
system( cmd);
}
}
return 1;
}
......@@ -1949,6 +1949,7 @@ void WttGtk::update_options_form()
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(build_debug_w), build_debug ? TRUE : FALSE);
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(build_crossref_w), build_crossref ? TRUE : FALSE);
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(build_manual_w), build_manual ? TRUE : FALSE);
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(build_nocopy_w), build_nocopy ? TRUE : FALSE);
}
......@@ -1972,15 +1973,16 @@ void WttGtk::set_options()
build_debug = (int) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(build_debug_w));
build_crossref = (int) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(build_crossref_w));
build_manual = (int) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(build_manual_w));
build_nocopy = (int) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(build_nocopy_w));
wnav->set_options( enable_comment, show_class, show_alias,
show_descrip, show_objref, show_objxref,
show_attrref, show_attrxref, build_force, build_debug,
build_crossref, build_manual);
show_descrip, show_objref, show_objxref,
show_attrref, show_attrxref, build_force, build_debug,
build_crossref, build_manual, build_nocopy);
wnavnode->set_options( enable_comment, show_class, show_alias,
show_descrip, show_objref, show_objxref,
show_attrref, show_attrxref, build_force, build_debug,
build_crossref, build_manual);
show_descrip, show_objref, show_objxref,
show_attrref, show_attrxref, build_force, build_debug,
build_crossref, build_manual, build_nocopy);
}
// Callbacks from the options form
......@@ -3011,9 +3013,9 @@ WttGtk::WttGtk(
gtk_paned_set_position( GTK_PANED(wnav_paned), window_width / 2);
wnav->get_options( &enable_comment, &show_class, &show_alias,
&show_descrip, &show_objref, &show_objxref,
&show_attrref, &show_attrxref, &build_force, &build_debug,
&build_crossref, &build_manual);
&show_descrip, &show_objref, &show_objxref,
&show_attrref, &show_attrxref, &build_force, &build_debug,
&build_crossref, &build_manual, &build_nocopy);
if ( wbctx && volid) {
wnav->volume_attached( wbctx, ldhses, 0);
......@@ -3140,6 +3142,7 @@ void WttGtk::create_options_dialog()
build_debug_w = gtk_check_button_new_with_label( "Debug");
build_crossref_w = gtk_check_button_new_with_label( "Crossreference");
build_manual_w = gtk_check_button_new_with_label( "Manual");
build_nocopy_w = gtk_check_button_new_with_label( "Disable Copy");
GtkWidget *build_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(build_vbox), build_label, FALSE, FALSE, 15);
......@@ -3147,6 +3150,7 @@ void WttGtk::create_options_dialog()
gtk_box_pack_start( GTK_BOX(build_vbox), build_debug_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(build_vbox), build_crossref_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(build_vbox), build_manual_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(build_vbox), build_nocopy_w, FALSE, FALSE, 7);
GtkWidget *hbox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox), hier_vbox, FALSE, FALSE, 50);
......
......@@ -99,6 +99,7 @@ class WttGtk : public Wtt {
GtkWidget *build_debug_w;
GtkWidget *build_crossref_w;
GtkWidget *build_manual_w;
GtkWidget *build_nocopy_w;
GtkWidget *menu_save_w;
GtkWidget *menu_revert_w;
GtkWidget *menu_cut_w;
......
This diff is collapsed.
......@@ -82,6 +82,7 @@ class wb_build : public wb_status
void export_import_files( int type, bld_ePass pass);
void export_files( bld_ePass pass) { export_import_files(bld_eType_Export, pass);}
void import_files( bld_ePass pass) { export_import_files(bld_eType_Import, pass);}
void update_file( char *dest, char *src);
wb_build_opt opt;
wb_session m_session;
......
......@@ -40,11 +40,12 @@
class wb_build_opt
{
public:
wb_build_opt() : force(0), debug(0), crossref(0), manual(0) {}
wb_build_opt() : force(0), debug(0), crossref(0), manual(0), nocopy(0) {}
int force;
int debug;
int crossref;
int manual;
int nocopy;
};
#endif
......@@ -2273,23 +2273,32 @@ pwr_tStatus lfu_SaveDirectoryVolume(
fprintf( file, "appl %s W "pwr_cNameAppl" $pwrp_load/\n",
nodename_ptr, "$pwrp_cnf/", nodename_ptr, *bus_number_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_PwrpAliasFile)
fprintf( file, "appl %s W $pwrp_cnf/%s/pwrp_alias.dat:$pwrp_cnf/pwrp_alias.dat $pwrp_load/pwrp_alias.dat\n",
nodename_ptr, nodename_ptr);
fprintf( file, "appl %s W $pwrp_load/pwrp_alias.dat $pwrp_load/pwrp_alias.dat\n",
nodename_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_IncludeFiles)
fprintf( file, "appl %s W $pwrp_inc/*.h\n", nodename_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_GraphFiles)
fprintf( file, "appl %s W $pwrp_exe/*.pwg\n", nodename_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_XMLFiles)
fprintf( file, "appl %s W $pwrp_load/*.xml\n", nodename_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_XttHelpFile)
if ( *components_ptr & pwr_mDistrComponentMask_XttHelpFile) {
fprintf( file, "appl %s W $pwrp_cnf/%s/xtt_help.dat:$pwrp_cnf/xtt_help.dat $pwrp_load/xtt_help.dat\n",
nodename_ptr, nodename_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_XttResourceFile)
fprintf( file, "appl %s W $pwrp_cnf/%s/b55/Rt_xtt:$pwrp_cnf/%s/Rt_xtt:$pwrp_cnf/Rt_xtt /home/b55/Rt_xtt\n",
fprintf( file, "appl %s S $pwrp_cnf/%s/%s_xtthelp.dat $pwrp_load/%s/%s__xtthelp.dat\n",
nodename_ptr, nodename_ptr, nodename_ptr, nodename_ptr, nodename_ptr);
}
if ( *components_ptr & pwr_mDistrComponentMask_XttResourceFile) {
fprintf( file, "appl %s W $pwrp_load/%s/b55/Rt_xtt:$pwrp_load/%s/Rt_xtt:$pwrp_load/Rt_xtt /home/b55/Rt_xtt\n",
nodename_ptr, nodename_ptr, nodename_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_XttSetupFile)
fprintf( file, "appl %s W $pwrp_cnf/%s/b55/xtt_setup.rtt_com:$pwrp_cnf/%s/xtt_setup.rtt_com:$pwrp_cnf/xtt_setup.rtt_com /home/b55/xtt_setup.rtt_com\n",
fprintf( file, "appl %s S $pwrp_load/%s/pwrp/Rt_xtt /home/pwrp/Rt_xtt\n",
nodename_ptr, nodename_ptr);
}
if ( *components_ptr & pwr_mDistrComponentMask_XttSetupFile) {
fprintf( file, "appl %s W $pwrp_load/%s/b55/xtt_setup.rtt_com:$pwrp_load/%s/xtt_setup.rtt_com:$pwrp_load/xtt_setup.rtt_com /home/b55/xtt_setup.rtt_com\n",
nodename_ptr, nodename_ptr, nodename_ptr);
fprintf( file, "appl %s S $pwrp_load/%s/pwrp/xtt_setup.rtt_com /home/pwrp/xtt_setup.rtt_com\n",
nodename_ptr, nodename_ptr);
}
if ( *components_ptr & pwr_mDistrComponentMask_FlowFiles)
fprintf( file, "appl %s W $pwrp_load/*.flw\n", nodename_ptr);
if ( *components_ptr & pwr_mDistrComponentMask_RHostsFile)
......@@ -2307,7 +2316,7 @@ pwr_tStatus lfu_SaveDirectoryVolume(
fprintf( file, "appl %s S $pwrp_web/*.pdf\n", nodename_ptr);
}
if ( *components_ptr & pwr_mDistrComponentMask_PwrpStop)
fprintf( file, "appl %s W $pwrp_cnf/%s/pwrp_stop.sh:$pwrp_exe/pwrp_stop.sh $pwrp_exe/pwrp_stop.sh\n",
fprintf( file, "appl %s W $pwrp_load/%s/pwrp_stop.sh:$pwrp_load/pwrp_stop.sh $pwrp_exe/pwrp_stop.sh\n",
nodename_ptr, nodename_ptr);
......
......@@ -2263,6 +2263,9 @@ int WNav::setup()
new WItemLocal( this, "Build.Manual", "setup_build_manual",
pwr_eType_Int32, sizeof( gbl.build.manual), 0, 1,
(void *) &gbl.build.manual, NULL, flow_eDest_IntoLast);
new WItemLocal( this, "Build.NoCopy", "setup_build_nocopy",
pwr_eType_Int32, sizeof( gbl.build.nocopy), 0, 1,
(void *) &gbl.build.nocopy, NULL, flow_eDest_IntoLast);
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
......@@ -2290,8 +2293,8 @@ int WNavGbl::symbolfile_exec( void *wnav)
}
void WNav::set_options( int ena_comment, int sh_class, int sh_alias, int sh_descrip,
int sh_objref, int sh_objxref, int sh_attrref, int sh_attrxref,
int bu_force, int bu_debug, int bu_crossref, int bu_manual)
int sh_objref, int sh_objxref, int sh_attrref, int sh_attrxref,
int bu_force, int bu_debug, int bu_crossref, int bu_manual, int bu_nocopy)
{
gbl.enable_comment = ena_comment;
gbl.show_class = sh_class;
......@@ -2305,12 +2308,13 @@ void WNav::set_options( int ena_comment, int sh_class, int sh_alias, int sh_desc
gbl.build.debug = bu_debug;
gbl.build.crossref = bu_crossref;
gbl.build.manual = bu_manual;
gbl.build.nocopy = bu_nocopy;
ldh_refresh( pwr_cNObjid);
}
void WNav::get_options( int *ena_comment, int *sh_class, int *sh_alias, int *sh_descrip,
int *sh_objref, int *sh_objxref, int *sh_attrref, int *sh_attrxref,
int *bu_force, int *bu_debug, int *bu_crossref, int *bu_manual)
int *sh_objref, int *sh_objxref, int *sh_attrref, int *sh_attrxref,
int *bu_force, int *bu_debug, int *bu_crossref, int *bu_manual, int *bu_nocopy)
{
*ena_comment = gbl.enable_comment;
*sh_class = gbl.show_class;
......@@ -2324,6 +2328,7 @@ void WNav::get_options( int *ena_comment, int *sh_class, int *sh_alias, int *sh_
*bu_debug = gbl.build.debug;
*bu_crossref = gbl.build.crossref;
*bu_manual = gbl.build.manual;
*bu_nocopy = gbl.build.nocopy;
}
int WNav::save_settnings( ofstream& fp)
......@@ -2396,6 +2401,11 @@ int WNav::save_settnings( ofstream& fp)
else
fp << " set nobuildmanual /local" << endl;
if ( gbl.build.nocopy)
fp << " set buildnocopy /local" << endl;
else
fp << " set nobuildnocopy /local" << endl;
if ( window_type == wnav_eWindowType_W1)
fp << "endif" << endl;
else if ( window_type == wnav_eWindowType_W2)
......
......@@ -404,11 +404,11 @@ class WNav : public WUtility{
void refresh();
void collapse();
void set_options( int ena_comment, int sh_class, int sh_alias, int sh_descrip,
int sh_objref, int sh_objxref, int sh_attrref, int sh_attrxref,
int bu_force, int bu_debug, int bu_crossref, int bu_manual);
int sh_objref, int sh_objxref, int sh_attrref, int sh_attrxref,
int bu_force, int bu_debug, int bu_crossref, int bu_manual, int bu_nocopy);
void get_options( int *ena_comment, int *sh_class, int *sh_alias, int *sh_descrip,
int *sh_objref, int *sh_objxref, int *sh_attrref, int *sh_attrxref,
int *bu_force, int *bu_debug, int *bu_crossref, int *bu_manual);
int *sh_objref, int *sh_objxref, int *sh_attrref, int *sh_attrxref,
int *bu_force, int *bu_debug, int *bu_crossref, int *bu_manual, int *bu_nocopy);
int save_settnings( ofstream& fp);
int node_to_objid( brow_tNode node, pwr_tObjid *objid);
int unselect_objid( pwr_tObjid objid);
......
......@@ -1309,6 +1309,20 @@ static int wnav_set_func( void *client_data,
else
wnav->gbl.build.manual = 0;
}
else if ( cdh_NoCaseStrncmp( arg1_str, "BUILDNOCOPY", strlen( arg1_str)) == 0)
{
if ( EVEN( dcli_get_qualifier( "/LOCAL", 0, 0)))
(wnav->gbl_command_cb)( wnav->parent_ctx, "SET BUILDNOCOPY");
else
wnav->gbl.build.nocopy = 1;
}
else if ( cdh_NoCaseStrncmp( arg1_str, "NOBUILDNOCOPY", strlen( arg1_str)) == 0)
{
if ( EVEN( dcli_get_qualifier( "/LOCAL", 0, 0)))
(wnav->gbl_command_cb)( wnav->parent_ctx, "SET NOBUILDNOCOPY");
else
wnav->gbl.build.nocopy = 0;
}
else if ( cdh_NoCaseStrncmp( arg1_str, "ENABLECOMMENT", strlen( arg1_str)) == 0)
{
if ( EVEN( dcli_get_qualifier( "/LOCAL", 0, 0)))
......
......@@ -186,6 +186,7 @@ class Wtt : public WUtility {
int build_debug;
int build_crossref;
int build_manual;
int build_nocopy;
int wnav_mapped;
int wnavnode_mapped;
WUted *utedctx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment