Alexandre Julliard : kernel32: Delete the . windows-label file if the label is empty.

Alexandre Julliard julliard at winehq.org
Fri Oct 17 07:26:14 CDT 2008


Module: wine
Branch: master
Commit: 1873ebdddc9d0656c593fd1aa2b3cd1df4dc2b5c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1873ebdddc9d0656c593fd1aa2b3cd1df4dc2b5c

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Oct 17 14:12:19 2008 +0200

kernel32: Delete the .windows-label file if the label is empty.

Add a trailing \n to the label file.

---

 dlls/kernel32/volume.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index 4214cca..823d163 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -723,6 +723,10 @@ BOOL WINAPI SetVolumeLabelW( LPCWSTR root, LPCWSTR label )
             WCHAR labelW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','l','a','b','e','l',0};
 
             labelW[0] = device[4];
+
+            if (!label[0])  /* delete label file when setting an empty label */
+                return DeleteFileW( labelW ) || GetLastError() == ERROR_FILE_NOT_FOUND;
+
             handle = CreateFileW( labelW, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
                                   CREATE_ALWAYS, 0, 0 );
             if (handle != INVALID_HANDLE_VALUE)
@@ -730,8 +734,9 @@ BOOL WINAPI SetVolumeLabelW( LPCWSTR root, LPCWSTR label )
                 char buffer[64];
                 DWORD size;
 
-                if (!WideCharToMultiByte( CP_UNIXCP, 0, label, -1, buffer, sizeof(buffer), NULL, NULL ))
-                    buffer[sizeof(buffer)-1] = 0;
+                if (!WideCharToMultiByte( CP_UNIXCP, 0, label, -1, buffer, sizeof(buffer)-1, NULL, NULL ))
+                    buffer[sizeof(buffer)-2] = 0;
+                strcat( buffer, "\n" );
                 WriteFile( handle, buffer, strlen(buffer), &size, NULL );
                 CloseHandle( handle );
                 return TRUE;




More information about the wine-cvs mailing list