michael@0: const Ci = Components.interfaces; michael@0: const Cc = Components.classes; michael@0: const NS_OS_TEMP_DIR = "TmpD"; michael@0: michael@0: const CWD = do_get_cwd(); michael@0: function checkOS(os) { michael@0: const nsILocalFile_ = "nsILocalFile" + os; michael@0: return nsILocalFile_ in Components.interfaces && michael@0: CWD instanceof Components.interfaces[nsILocalFile_]; michael@0: } michael@0: michael@0: const isWin = checkOS("Win"); michael@0: const isMac = checkOS("Mac"); michael@0: const isUnix = !(isWin || isMac); michael@0: michael@0: var hiddenUnixFile; michael@0: function createUNIXHiddenFile() { michael@0: var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); michael@0: var tmpDir = dirSvc.get(NS_OS_TEMP_DIR, Ci.nsIFile); michael@0: hiddenUnixFile = tmpDir.clone(); michael@0: hiddenUnixFile.append(".foo"); michael@0: // we don't care if this already exists because we don't care michael@0: // about the file's contents (just the name) michael@0: if (!hiddenUnixFile.exists()) michael@0: hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); michael@0: return hiddenUnixFile.exists(); michael@0: } michael@0: michael@0: function run_test() { michael@0: // Skip this test on Windows michael@0: if (isWin) michael@0: return; michael@0: michael@0: do_check_true(createUNIXHiddenFile()); michael@0: do_check_true(hiddenUnixFile.isHidden()); michael@0: } michael@0: