equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
173 } |
173 } |
174 |
174 |
175 int _wunlink(const wchar_t* wc) |
175 int _wunlink(const wchar_t* wc) |
176 { |
176 { |
177 int ret = 0; |
177 int ret = 0; |
178 int len = wcstombs(0,wc,-1); |
178 const int len = wcstombs(0,wc,-1); |
179 char *tmp = new char[len]; |
179 |
|
180 char* tmp = new char[len+1]; |
180 ret = wcstombs(tmp, wc, len); |
181 ret = wcstombs(tmp, wc, len); |
|
182 |
181 if(ret == -1) { |
183 if(ret == -1) { |
182 printf("wunlink: wcstombs error\n"); |
184 printf("wunlink: wcstombs error\n"); |
183 delete[] tmp; |
185 delete [] tmp; |
184 return ret; |
186 return ret; |
185 } |
187 } |
|
188 |
186 tmp[ret] = '\0'; |
189 tmp[ret] = '\0'; |
187 ret = unlink(tmp); |
190 ret = unlink(tmp); |
|
191 |
188 if(ret != 0) |
192 if(ret != 0) |
189 printf("wunlink: %s: %s\n", tmp, strerror(ret)); |
193 printf("wunlink: %s: %s\n", tmp, strerror(ret)); |
|
194 |
|
195 delete [] tmp; |
190 return ret; |
196 return ret; |
191 } |
197 } |
192 |
198 |
193 int GetTempPathW(unsigned int maxlen, const wchar_t *ptr) |
199 int GetTempPathW(unsigned int maxlen, const wchar_t *ptr) |
194 { |
200 { |
619 } |
625 } |
620 return retValue; |
626 return retValue; |
621 } |
627 } |
622 |
628 |
623 |
629 |
624 |
630 int FileCopyA(const char* aSrc, const char* aDest, size_t aFlag) |
625 |
631 { |
|
632 int err= 0; |
|
633 const int len = 512; |
|
634 // Overwrites the orphaned file(if any). |
|
635 char cmd[ len ] = "cp -f "; |
|
636 strcat(cmd, aSrc); |
|
637 strcat(cmd, " "); |
|
638 strcat(cmd, aDest); |
|
639 strcat(cmd, " 2> /dev/null"); |
|
640 |
|
641 err = system(cmd); |
|
642 |
|
643 return err; |
|
644 } |
|
645 |
|
646 int FileMoveA(const char* aSrc, const char* aDest) |
|
647 { |
|
648 int err= 0; |
|
649 |
|
650 // Overwrites the orphaned file(if any). |
|
651 char cmd[ 512 ] = "mv -f "; |
|
652 strcat(cmd, aSrc); |
|
653 strcat(cmd, " "); |
|
654 strcat(cmd, aDest); |
|
655 strcat(cmd, " 2> /dev/null"); |
|
656 |
|
657 err = system(cmd); |
|
658 |
|
659 return err; |
|
660 } |
|
661 |