|
1 const Ci = Components.interfaces; |
|
2 const Cc = Components.classes; |
|
3 const NS_OS_TEMP_DIR = "TmpD"; |
|
4 |
|
5 const CWD = do_get_cwd(); |
|
6 function checkOS(os) { |
|
7 const nsILocalFile_ = "nsILocalFile" + os; |
|
8 return nsILocalFile_ in Components.interfaces && |
|
9 CWD instanceof Components.interfaces[nsILocalFile_]; |
|
10 } |
|
11 |
|
12 const isWin = checkOS("Win"); |
|
13 const isMac = checkOS("Mac"); |
|
14 const isUnix = !(isWin || isMac); |
|
15 |
|
16 var hiddenUnixFile; |
|
17 function createUNIXHiddenFile() { |
|
18 var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); |
|
19 var tmpDir = dirSvc.get(NS_OS_TEMP_DIR, Ci.nsIFile); |
|
20 hiddenUnixFile = tmpDir.clone(); |
|
21 hiddenUnixFile.append(".foo"); |
|
22 // we don't care if this already exists because we don't care |
|
23 // about the file's contents (just the name) |
|
24 if (!hiddenUnixFile.exists()) |
|
25 hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); |
|
26 return hiddenUnixFile.exists(); |
|
27 } |
|
28 |
|
29 function run_test() { |
|
30 // Skip this test on Windows |
|
31 if (isWin) |
|
32 return; |
|
33 |
|
34 do_check_true(createUNIXHiddenFile()); |
|
35 do_check_true(hiddenUnixFile.isHidden()); |
|
36 } |
|
37 |