Update of /cvsroot/libsysio/libsysio/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19371/tests
Modified Files:
Tag: RELEASE_1_3
test_regions.c
Log Message:
Add -e switch in order to work with existing files.
Index: test_regions.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/tests/test_regions.c,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -w -b -B -p -r1.9 -r1.9.2.1
--- test_regions.c 1 May 2007 16:33:53 -0000 1.9
+++ test_regions.c 17 Jun 2008 14:42:34 -0000 1.9.2.1
@@ -62,7 +62,7 @@
/*
* Copy one file to another.
*
- * Usage: test_regions [-x] \
+ * Usage: test_regions [-x] [-e] \
* {r,w} <off> <count> <path>
*
* Destination will not be overwritten if it already exist.
@@ -85,6 +85,7 @@ int
main(int argc, char * const argv[])
{
int i;
+ int keep;
int err;
long l;
off_t off;
@@ -104,6 +105,7 @@ main(int argc, char * const argv[])
/*
* Parse command-line args.
*/
+ keep = 0;
while ((i = getopt(argc,
argv,
#ifdef __GLIBC__
@@ -112,7 +114,7 @@ main(int argc, char * const argv[])
#ifdef GO64
"x"
#endif
- "")) != -1)
+ "e")) != -1)
switch (i) {
#ifdef GO64
@@ -120,6 +122,9 @@ main(int argc, char * const argv[])
use64 = 1;
break;
#endif
+ case 'e':
+ keep = 1;
+ break;
default:
usage();
}
@@ -181,7 +186,10 @@ main(int argc, char * const argv[])
(void )memset(buf, 0, nbytes);
err = 0;
- flags = which == 'r' ? O_RDONLY : (O_WRONLY|O_CREAT|O_EXCL);
+ flags = 0;
+ if (!keep)
+ flags |= O_CREAT|O_EXCL;
+ flags |= which == 'r' ? O_RDONLY : O_WRONLY;
#ifdef GO64
if (use64)
flags |= O_LARGEFILE;
|