@@ -496,11 +496,13 @@ 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
@@ -555,10 +557,31 @@ class TestFileManager : XCTestCase {
555
557
556
558
XCTAssertNotNil ( try ? fm. createDirectory ( atPath: subDirs1, withIntermediateDirectories: true , attributes: nil ) )
557
559
XCTAssertNotNil ( try ? fm. createDirectory ( atPath: subDirs2, withIntermediateDirectories: true , attributes: nil ) )
558
- for filename in [ itemPath1, itemPath2, itemPath3, hiddenItem1 , hiddenItem2 , hiddenItem3 , hiddenItem4 ] {
560
+ for filename in [ itemPath1, itemPath2, itemPath3] {
559
561
XCTAssertTrue ( fm. createFile ( atPath: filename, contents: Data ( ) , attributes: nil ) , " Cant create file ' \( filename) ' " )
560
562
}
561
563
564
+ var resourceValues = URLResourceValues ( )
565
+ resourceValues. isHidden = true
566
+ for filename in [ hiddenItem1, hiddenItem2, hiddenItem3, hiddenItem4] {
567
+ XCTAssertTrue ( fm. createFile ( atPath: filename, contents: Data ( ) , attributes: nil ) , " Cant create file ' \( filename) ' " )
568
+ do {
569
+ var url = URL ( fileURLWithPath: filename)
570
+ try url. setResourceValues ( resourceValues)
571
+ } catch {
572
+ XCTFail ( " Couldn't make \( filename) a hidden file " )
573
+ }
574
+ }
575
+
576
+ do {
577
+ var hiddenURL1 = URL ( fileURLWithPath: hiddenDir1)
578
+ var hiddenURL2 = URL ( fileURLWithPath: hiddenDir2)
579
+ try hiddenURL1. setResourceValues ( resourceValues)
580
+ try hiddenURL2. setResourceValues ( resourceValues)
581
+ } catch {
582
+ XCTFail ( " Couldn't make \( hiddenDir1) and \( hiddenDir2) hidden directories " )
583
+ }
584
+
562
585
if let foundItems = directoryItems ( options: [ ] ) {
563
586
XCTAssertEqual ( foundItems. count, fileLevels. count)
564
587
for (name, level) in foundItems {
0 commit comments