subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1433848 - in /subversion/branches/fsfs-format7/subversion: include/svn_io.h libsvn_subr/io.c
Date Wed, 16 Jan 2013 08:10:54 GMT
Author: stefan2
Date: Wed Jan 16 08:10:53 2013
New Revision: 1433848

URL: http://svn.apache.org/viewvc?rev=1433848&view=rev
Log:
On the fsfs-format7 branch: Rev the svn_io_file_create API to allow
for binary strings as well.

* subversion/include/svn_io.h
  (svn_io_file_create2): rev'ed API
  (svn_io_file_create): deprecate
* subversion/libsvn_subr/io.c
  (svn_io_file_create2): implement
  (svn_io_file_create): implement in terms of the new API

Modified:
    subversion/branches/fsfs-format7/subversion/include/svn_io.h
    subversion/branches/fsfs-format7/subversion/libsvn_subr/io.c

Modified: subversion/branches/fsfs-format7/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/include/svn_io.h?rev=1433848&r1=1433847&r2=1433848&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/include/svn_io.h (original)
+++ subversion/branches/fsfs-format7/subversion/include/svn_io.h Wed Jan 16 08:10:53 2013
@@ -678,12 +678,28 @@ svn_io_files_contents_three_same_p(svn_b
 /** Create file at utf8-encoded @a file with contents @a contents.
  * @a file must not already exist.
  * Use @a pool for memory allocations.
+ *
+ * @deprecated Provided for backward compatibility with the 1.8 API.
  */
 svn_error_t *
 svn_io_file_create(const char *file,
                    const char *contents,
                    apr_pool_t *pool);
 
+/** Create file at utf8-encoded @a file with binary contents @a contents
+ * of @a length bytes.  If the latter is 0 and @a contents is not, @a length
+ * will be set to the C string length of @a contents.
+ * @a file must not already exist.
+ * Use @a pool for memory allocations.
+ *
+ * @since New in 1.9.
+ */
+svn_error_t *
+svn_io_file_create2(const char *file,
+                    const char *contents,
+                    apr_size_t length,
+                    apr_pool_t *pool);
+
 /**
  * Lock file at @a lock_file. If @a exclusive is TRUE,
  * obtain exclusive lock, otherwise obtain shared lock.

Modified: subversion/branches/fsfs-format7/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_subr/io.c?rev=1433848&r1=1433847&r2=1433848&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_subr/io.c Wed Jan 16 08:10:53 2013
@@ -1143,6 +1143,14 @@ svn_error_t *svn_io_file_create(const ch
                                 const char *contents,
                                 apr_pool_t *pool)
 {
+  return svn_error_trace(svn_io_file_create2(file, contents, 0, pool));
+}
+
+svn_error_t *svn_io_file_create2(const char *file,
+                                 const char *contents,
+                                 apr_size_t length,
+                                 apr_pool_t *pool)
+{
   apr_file_t *f;
   apr_size_t written;
   svn_error_t *err = SVN_NO_ERROR;
@@ -1151,10 +1159,13 @@ svn_error_t *svn_io_file_create(const ch
                            (APR_WRITE | APR_CREATE | APR_EXCL),
                            APR_OS_DEFAULT,
                            pool));
-  if (contents && *contents)
-    err = svn_io_file_write_full(f, contents, strlen(contents),
-                                 &written, pool);
-
+  if (contents)
+    {
+      if (length == 0)
+        length = strlen(contents);
+      if (length)
+        err = svn_io_file_write_full(f, contents, length, &written, pool);
+    }
 
   return svn_error_trace(
                         svn_error_compose_create(err,



Mime
View raw message