You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2014/03/13 20:25:01 UTC

svn commit: r1577292 - /subversion/trunk/subversion/libsvn_subr/stream.c

Author: rhuijben
Date: Thu Mar 13 19:25:01 2014
New Revision: 1577292

URL: http://svn.apache.org/r1577292
Log:
* subversion/libsvn_subr/stream.c
  (_FILE_DISPOSITION_INFO,
   FileDispositionInfo): Define when not using a recent enough SDK.
  (svn_stream__install_delete): Add an optimized codepath for WIN32.

Modified:
    subversion/trunk/subversion/libsvn_subr/stream.c

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1577292&r1=1577291&r2=1577292&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Thu Mar 13 19:25:01 2014
@@ -2005,7 +2005,12 @@ typedef struct _FILE_RENAME_INFO {
   WCHAR  FileName[1];
 } FILE_RENAME_INFO, *PFILE_RENAME_INFO;
 
+typedef struct _FILE_DISPOSITION_INFO {
+  BOOL DeleteFile;
+} FILE_DISPOSITION_INFO, *PFILE_DISPOSITION_INFO;
+
 #define FileRenameInfo 3
+#define FileDispositionInfo 4
 
 typedef BOOL (WINAPI *SetFileInformationByHandle_t)(HANDLE hFile,
                                                     int FileInformationClass,
@@ -2340,13 +2345,37 @@ svn_stream__install_delete(svn_stream_t 
   struct install_baton_t *ib = install_stream->baton;
 
 #ifdef WIN32
-  /* ### TODO: Optimize windows case */
-  {
-    apr_file_t *file = svn_stream__aprfile(install_stream);
-
-    if (file)
-      SVN_ERR(svn_io_file_close(file, scratch_pool));
-  }
+  BOOL done;
+
+#if _WIN32_WINNT < 0x600
+
+  SVN_ERR(svn_atomic__init_once(&SetFileInformationByHandle_a,
+                                find_SetFileInformationByHandle,
+                                NULL, scratch_pool));
+
+  if (!SetFileInformationByHandle_p)
+    done = FALSE;
+  else
+#endif /* WIN32 < Windows Vista */
+    {
+      FILE_DISPOSITION_INFO disposition_info;
+      HANDLE hFile;
+
+      apr_os_file_get(&hFile, ib->baton_apr.file);
+
+      disposition_info.DeleteFile = TRUE;
+
+      /* Mark the file as delete on close to avoid having to reopen
+         the file as part of the delete handling. */
+      done = SetFileInformationByHandle(hFile, FileDispositionInfo,
+                                        &disposition_info,
+                                        sizeof(disposition_info));
+    }
+
+   SVN_ERR(svn_io_file_close(ib->baton_apr.file, scratch_pool));
+
+   if (done)
+     return SVN_NO_ERROR; /* File is already gone */
 #endif
 
   return svn_error_trace(svn_io_remove_file2(ib->tmp_path, FALSE,