|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: FileTestUtils |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <errno.h> |
|
20 #include "filetestutils.h" |
|
21 |
|
22 using namespace std; |
|
23 using namespace java::filetest; |
|
24 |
|
25 |
|
26 void FileTestUtils::createReadOnlyFile(const wstring &aPath) |
|
27 { |
|
28 FileTestUtils::createFile(aPath, O_CREAT|O_EXCL|O_RDONLY); |
|
29 } |
|
30 |
|
31 void FileTestUtils::createWriteOnlyFile(const wstring &aPath) |
|
32 { |
|
33 FileTestUtils::createFile(aPath, O_CREAT|O_EXCL|O_WRONLY); |
|
34 } |
|
35 |
|
36 void FileTestUtils::createNormalFile(const wstring& aPath) |
|
37 { |
|
38 FileTestUtils::createFile(aPath, O_CREAT|O_EXCL); |
|
39 } |
|
40 |
|
41 void FileTestUtils::checkError(const wstring& aString,const int aErr) |
|
42 { |
|
43 if (0 > aErr) |
|
44 { |
|
45 printf("Errno: %d: Path: %S\n", errno, aString.c_str()); |
|
46 exit(aErr); |
|
47 } |
|
48 } |
|
49 |
|
50 void FileTestUtils::createReadOnlyDir(const wstring& aPath) |
|
51 { |
|
52 FileTestUtils::createDirMode(aPath, 0444); |
|
53 } |
|
54 |
|
55 void FileTestUtils::createDir(const wstring &aPath) |
|
56 { |
|
57 FileTestUtils::createDirMode(aPath, 0777); |
|
58 } |
|
59 |
|
60 |
|
61 void FileTestUtils::createHiddenFile(const wstring &aPath, const wstring &aFile) |
|
62 { |
|
63 //In linux, we just rename aFIle with "."+aFile and then create a file. :-) |
|
64 FileTestUtils::createNormalFile(aPath+aFile); |
|
65 FileTestUtils::setFileHidden(aPath, aFile); |
|
66 } |
|
67 |