Mercurial > projects > dwt-linux
changeset 268:5995c228c72f
Fix: string termination
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 15:35:58 +0200 |
parents | 6383fb4cdfc3 |
children | 11015f58425e |
files | dwt/dnd/FileTransfer.d |
diffstat | 1 files changed, 9 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/dnd/FileTransfer.d Sun Jul 06 15:35:34 2008 +0200 +++ b/dwt/dnd/FileTransfer.d Sun Jul 06 15:35:58 2008 +0200 @@ -66,11 +66,11 @@ * represented by a java <code>String[]</code> to a platform specific representation. * Each <code>String</code> in the array contains the absolute path for a single * file or directory. - * + * * @param object a java <code>String[]</code> containing the file names to be converted * @param transferData an empty <code>TransferData</code> object that will * be filled in on return with the platform specific format of the data - * + * * @see Transfer#nativeToJava */ public override void javaToNative(Object object, TransferData transferData) { @@ -121,7 +121,7 @@ * @param transferData the platform specific representation of the data to be converted * @return a java <code>String[]</code> containing a list of file names if the conversion * was successful; otherwise null - * + * * @see Transfer#javaToNative */ public override Object nativeToJava(TransferData transferData) { @@ -133,26 +133,18 @@ if (temp[i] is '\r' && temp[i+1] is '\n') { int size = i - offset; char* file = cast(char*)OS.g_malloc(size + 1); - String fileBuffer = new char[size + 1]; - System.arraycopy(temp, offset, fileBuffer, 0, size); - file[ 0 .. size + 1 ] = fileBuffer; - char*[] newFiles = new char*[files.length + 1]; - SimpleType!(char*).arraycopy(files, 0, newFiles, 0, files.length); - newFiles[files.length] = file; - files = newFiles; + file[ 0 .. size ] = temp[ offset .. offset+size ]; + file[ size ] = '\0'; + files ~= file; offset = i + 2; } } if (offset < temp.length - 2) { int size = temp.length - offset; char* file = cast(char*)OS.g_malloc(size + 1); - String fileBuffer = new char[size + 1]; - System.arraycopy(temp, offset, fileBuffer, 0, size); - file[ 0 .. size+1 ] = fileBuffer; - char*[] newFiles = new char*[files.length + 1]; - SimpleType!(char*).arraycopy(files, 0, newFiles, 0, files.length); - newFiles[files.length] = file; - files = newFiles; + file[ 0 .. size ] = temp[ offset .. offset+size ]; + file[ size ] = '\0'; + files ~= file; } String[] fileNames; for (int i = 0; i < files.length; i++) {