@@ -496,15 +496,18 @@ class TestFileManager : XCTestCase {
496
496
func test_directoryEnumerator( ) {
497
497
let fm = FileManager . default
498
498
let basePath = NSTemporaryDirectory ( ) + " testdir \( NSUUID ( ) . uuidString) / "
499
- let subDirs1 = basePath + " subdir1/subdir2/.hiddenDir/subdir3/ "
499
+ let hiddenDir1 = basePath + " subdir1/subdir2/.hiddenDir/ "
500
+ let subDirs1 = hiddenDir1 + " subdir3/ "
500
501
let itemPath1 = basePath + " itemFile1 "
501
502
#if os(Windows)
502
503
// Filenames ending with '.' are not valid on Windows, so don't bother testing them
503
- let subDirs2 = basePath + " subdir1/subdir2/subdir4.app/subdir5/.subdir6.ext/subdir7.ext/ "
504
+ let hiddenDir2 = basePath + " subdir1/subdir2/subdir4.app/subdir5/.subdir6.ext/ "
505
+ let subDirs2 = hiddenDir2 + " subdir7.ext/ "
504
506
let itemPath2 = subDirs1 + " itemFile2 "
505
507
let itemPath3 = subDirs1 + " itemFile3.ext "
506
508
#else
507
- let subDirs2 = basePath + " subdir1/subdir2/subdir4.app/subdir5./.subdir6.ext/subdir7.ext./ "
509
+ let hiddenDir2 = basePath + " subdir1/subdir2/subdir4.app/subdir5./.subdir6.ext/ "
510
+ let subDirs2 = hiddenDir2 + " subdir7.ext./ "
508
511
let itemPath2 = subDirs1 + " itemFile2. "
509
512
let itemPath3 = subDirs1 + " itemFile3.ext. "
510
513
#endif
@@ -555,10 +558,31 @@ class TestFileManager : XCTestCase {
555
558
556
559
XCTAssertNotNil ( try ? fm. createDirectory ( atPath: subDirs1, withIntermediateDirectories: true , attributes: nil ) )
557
560
XCTAssertNotNil ( try ? fm. createDirectory ( atPath: subDirs2, withIntermediateDirectories: true , attributes: nil ) )
558
- for filename in [ itemPath1, itemPath2, itemPath3, hiddenItem1 , hiddenItem2 , hiddenItem3 , hiddenItem4 ] {
561
+ for filename in [ itemPath1, itemPath2, itemPath3] {
559
562
XCTAssertTrue ( fm. createFile ( atPath: filename, contents: Data ( ) , attributes: nil ) , " Cant create file ' \( filename) ' " )
560
563
}
561
564
565
+ var resourceValues = URLResourceValues ( )
566
+ resourceValues. isHidden = true
567
+ for filename in [ hiddenItem1, hiddenItem2, hiddenItem3, hiddenItem4] {
568
+ XCTAssertTrue ( fm. createFile ( atPath: filename, contents: Data ( ) , attributes: nil ) , " Cant create file ' \( filename) ' " )
569
+ do {
570
+ var url = URL ( fileURLWithPath: filename)
571
+ try url. setResourceValues ( resourceValues)
572
+ } catch {
573
+ XCTFail ( " Couldn't make \( filename) a hidden file " )
574
+ }
575
+ }
576
+
577
+ do {
578
+ var hiddenURL1 = URL ( fileURLWithPath: hiddenDir1)
579
+ var hiddenURL2 = URL ( fileURLWithPath: hiddenDir2)
580
+ try hiddenURL1. setResourceValues ( resourceValues)
581
+ try hiddenURL2. setResourceValues ( resourceValues)
582
+ } catch {
583
+ XCTFail ( " Couldn't make \( hiddenDir1) and \( hiddenDir2) hidden directories " )
584
+ }
585
+
562
586
if let foundItems = directoryItems ( options: [ ] ) {
563
587
XCTAssertEqual ( foundItems. count, fileLevels. count)
564
588
for (name, level) in foundItems {
0 commit comments