File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
swift/ql/test/library-tests/dataflow/flowsources Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ // --- stubs ---
2
+
3
+ class NSObject {
4
+ }
5
+
6
+ struct URL {
7
+ }
8
+
9
+ struct URLResourceKey {
10
+ }
11
+
12
+ struct Data {
13
+ }
14
+
15
+ class FileManager : NSObject {
16
+ struct DirectoryEnumerationOptions : OptionSet {
17
+ let rawValue : Int
18
+ }
19
+
20
+ func contentsOfDirectory( at url: URL , includingPropertyForKeys keys: [ URLResourceKey ] ? , options mask: FileManager . DirectoryEnumerationOptions = [ ] ) throws -> [ URL ] { return [ ] }
21
+ func contentsOfDirectory( atPath path: String ) throws -> [ String ] { return [ ] }
22
+ func directoryContents( atPath path: String ) -> [ Any ] ? { return [ ] } // returns array of NSString
23
+ func subpathsOfDirectory( atPath path: String ) throws -> [ String ] { return [ ] }
24
+ func subpaths( atPath path: String ) -> [ String ] ? { return [ ] }
25
+
26
+ func destinationOfSymbolicLink( atPath path: String ) throws -> String { return " " }
27
+ func pathContentOfSymbolicLink( atPath path: String ) -> String ? { return " " }
28
+
29
+ func contents( atPath path: String ) -> Data ? { return nil }
30
+ }
31
+
32
+ // --- tests ---
33
+
34
+ func testFileHandle( fm: FileManager , url: URL , path: String ) {
35
+ do
36
+ {
37
+ let contents1 = try fm. contentsOfDirectory ( at: url, includingPropertyForKeys: nil ) // SOURCE
38
+ let content1 = contents1 [ 0 ]
39
+ let contents2 = try fm. contentsOfDirectory ( atPath: path) // SOURCE
40
+ let contents3 = fm. directoryContents ( atPath: path) ! // SOURCE
41
+
42
+ let subpaths1 = try fm. subpathsOfDirectory ( atPath: path) // SOURCE
43
+ let subpaths2 = fm. subpaths ( atPath: path) ! // SOURCE
44
+
45
+ let link1 = try fm. destinationOfSymbolicLink ( atPath: path) // SOURCE
46
+ let link2 = fm. pathContentOfSymbolicLink ( atPath: path) ! // SOURCE
47
+
48
+ let data = fm. contents ( atPath: path) ! // SOURCE
49
+ } catch {
50
+ // ...
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments