Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1550 - trunk: . fsvs/src

fsvs
Discussion topic

Back to topic list

svn commit: r1550 - trunk: . fsvs/src

Author pmarek
Full name P.Marek
Date 2008-03-16 23:08:11 PDT
Message Author: pmarek
Date: 2008-03-16 23:08:10-0700
New Revision: 1550

Modified:
   trunk/ (props changed)
   trunk/fsvs/src/waa.c
   trunk/fsvs/src/waa.h

Log:
Implement WAA__APPEND for waa__open().


Modified: trunk/fsvs/src/waa.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/waa​.c?view=diff&rev​=1550&p1=trunk/f​svs/src/waa.c&p2​=trunk/fsvs/src/waa.​c&r1=1549&r2​=1550
====================​====================​====================​==================
--- trunk/fsvs/src/waa.c (original)
+++ trunk/fsvs/src/waa.c 2008-03-16 23:08:10-0700
@@ -458,9 +458,13 @@
  * the file is opened as a temporary file and \b must be closed with
  * waa__close(); depending on the success value given there it is renamed
  * to the destination name or deleted.
+ *
  * This temporary path is stored in a per-filehandle array, so there's no
  * limit here on the number of written-to files.
  *
+ * If the flags include \c O_APPEND, no temporary file is used, and no
+ * filehandle is stored - do simply a \c close().
+ *
  * For read-only files simply do a \c close() on their filehandles.
  *
  * Does return \c ENOENT without telling the user.
@@ -476,13 +480,19 @@
 {
     char *cp, *orig, *eos, *dest, *start_spec;
     int fh, status;
- int to_be_written_to;
+ int use_temp_file;
 
 
     fh=-1;
     orig=NULL;
 
- to_be_written_to=flags & (O_WRONLY | O_RDWR | O_CREAT);
+ /* O_APPEND means that we have to append to the *existing* file, so we
+ * may not use the temporaray name.
+ * But using O_APPEND normally means using O_CREAT, too - so we have to
+ * do the specifically. */
+ use_temp_file=(flags & O_APPEND) ? 0 :
+ (flags & (O_WRONLY | O_RDWR | O_CREAT));
+
     STOPIF( waa__get_waa_directory(path, &dest, &eos, &start_spec,
                 waa__get_gwd_flag(extension) ), NULL);
 
@@ -495,7 +505,7 @@
     }
 
     strcpy(eos, extension);
- if (to_be_written_to)
+ if (use_temp_file)
     {
         orig=strdup(dest);
         STOPIF_ENOMEM(!orig);
@@ -528,6 +538,10 @@
         DEBUGP("reading target %s", dest);
 
 
+ if (flags & O_APPEND)
+ STOPIF( waa__mkdir(dest, 0), NULL);
+
+
     /* in case there's a O_CREAT */
     fh=open(dest, flags, 0777);
     if (fh<0)

Modified: trunk/fsvs/src/waa.h
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/waa​.h?view=diff&rev​=1550&p1=trunk/f​svs/src/waa.h&p2​=trunk/fsvs/src/waa.​h&r1=1549&r2​=1550
====================​====================​====================​==================
--- trunk/fsvs/src/waa.h (original)
+++ trunk/fsvs/src/waa.h 2008-03-16 23:08:10-0700
@@ -167,6 +167,7 @@
  * @{ */
 #define WAA__WRITE (O_WRONLY | O_CREAT | O_TRUNC)
 #define WAA__READ (O_RDONLY)
+#define WAA__APPEND (O_APPEND | O_CREAT)
 /** @} */
 /** @} */

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r1550 - trunk: . fsvs/src pmarek P.Marek 2008-03-16 23:08:11 PDT
Messages per page: