[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/csant csant_task.c,1.5,1.6
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/csant csant_task.c,1.5,1.6 |
Date: |
Fri, 31 Jan 2003 00:40:24 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/csant
In directory subversions:/tmp/cvs-serv20679/csant
Modified Files:
csant_task.c
Log Message:
Add the "mkdir" and "copy" tasks to csant.
Index: csant_task.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csant/csant_task.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** csant_task.c 21 Dec 2002 01:53:37 -0000 1.5
--- csant_task.c 31 Jan 2003 05:40:21 -0000 1.6
***************
*** 20,23 ****
--- 20,33 ----
#include "csant_defs.h"
+ #ifdef HAVE_SYS_TYPES_H
+ #include <sys/types.h>
+ #endif
+ #ifdef HAVE_SYS_STAT_H
+ #include <sys/stat.h>
+ #endif
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+ #include <errno.h>
#ifdef __cplusplus
***************
*** 85,95 ****
if(!file)
{
! fprintf(stderr,"no file to delete in <delete>\n");
return 0;
}
! retval=ILDeleteFile(file);
! if(retval && fail && !strcmp(fail,"true"))
{
! fprintf(stderr,"could not delete '%s'\n",file);
return 0;
}
--- 95,116 ----
if(!file)
{
! fprintf(stderr, "no file to delete in <delete>\n");
return 0;
}
! if(!CSAntSilent)
{
! if(!fail || ILStrICmp(fail, "true") != 0)
! {
! printf("rm -f %s\n", file);
! }
! else
! {
! printf("rm %s\n", file);
! }
! }
! retval = ILDeleteFile(file);
! if(retval && fail && !ILStrICmp(fail, "true"))
! {
! perror(file);
return 0;
}
***************
*** 98,101 ****
--- 119,226 ----
/*
+ * Make a directory.
+ */
+ static int Task_Mkdir(CSAntTask *task)
+ {
+ const char *dir = CSAntTaskParam(task, "dir");
+ int retval;
+ if(!dir)
+ {
+ fprintf(stderr, "no directory to make in <mkdir>\n");
+ return 0;
+ }
+ if(!CSAntSilent)
+ {
+ printf("mkdir %s\n", dir);
+ }
+ #ifdef IL_WIN32_NATIVE
+ retval = mkdir(dir);
+ #else
+ retval = mkdir(dir, 0777);
+ #endif
+ if(retval && errno != EEXIST)
+ {
+ perror(dir);
+ return 0;
+ }
+ return 1;
+ }
+
+ /*
+ * Copy a file.
+ */
+ static int Task_Copy(CSAntTask *task)
+ {
+ const char *fromfile = CSAntTaskParam(task, "file");
+ const char *tofile = CSAntTaskParam(task, "tofile");
+ FILE *instream;
+ FILE *outstream;
+ char buffer[BUFSIZ];
+ int len;
+
+ /* Validate the parameters */
+ if(!fromfile)
+ {
+ fprintf(stderr, "no source file in <copy>\n");
+ return 0;
+ }
+ if(!tofile)
+ {
+ fprintf(stderr, "no destination file in <copy>\n");
+ return 0;
+ }
+
+ /* Report the command that we will be executing */
+ if(!CSAntSilent)
+ {
+ printf("cp %s %s\n", fromfile, tofile);
+ }
+
+ /* Attempt to open the source file */
+ if((instream = fopen(fromfile, "rb")) == NULL)
+ {
+ if((instream = fopen(fromfile, "r")) == NULL)
+ {
+ perror(fromfile);
+ return 0;
+ }
+ }
+
+ /* Attempt to open the destination file */
+ if((outstream = fopen(tofile, "wb")) == NULL)
+ {
+ if((outstream = fopen(tofile, "w")) == NULL)
+ {
+ perror(tofile);
+ fclose(instream);
+ return 0;
+ }
+ }
+
+ /* Copy the file's contents */
+ while((len = (int)fread(buffer, 1, BUFSIZ, instream)) >= BUFSIZ)
+ {
+ fwrite(buffer, 1, len, outstream);
+ }
+ if(len > 0)
+ {
+ fwrite(buffer, 1, len, outstream);
+ }
+ if(ferror(outstream))
+ {
+ perror(tofile);
+ fclose(instream);
+ fclose(outstream);
+ ILDeleteFile(tofile);
+ return 0;
+ }
+
+ /* Done */
+ fclose(instream);
+ fclose(outstream);
+ return 1;
+ }
+
+ /*
* Invoke a sub-process containing another invocation of "csant".
*/
***************
*** 194,199 ****
{"echo", Task_Echo},
{"fail", Task_Fail},
- {"csant", Task_CSAnt},
{"delete", Task_Delete},
};
int const CSAntNumTasks = (sizeof(CSAntTasks) / sizeof(CSAntTaskInfo));
--- 319,327 ----
{"echo", Task_Echo},
{"fail", Task_Fail},
{"delete", Task_Delete},
+ {"mkdir", Task_Mkdir},
+ {"copy", Task_Copy},
+ {"csant", Task_CSAnt},
+ {"nant", Task_CSAnt},
};
int const CSAntNumTasks = (sizeof(CSAntTasks) / sizeof(CSAntTaskInfo));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/csant csant_task.c,1.5,1.6,
Rhys Weatherley <address@hidden> <=