1
2
3
4
5
6 using System;
7 using System.Collections;
8
9 namespace System.IO
10 {
11 public static class Directory
12 {
13 public static nothrow bool Exists(const string& directoryPath)
14 {
15 return RtDirectoryExists(directoryPath.Chars());
16 }
17 public static nothrow void CreateDirectories(const string& directoryPath)
18 {
19 RtCreateDirectories(directoryPath.Chars());
20 }
21 public static List<string> GetFiles(const string& directoryPath)
22 {
23 List<string> files;
24 int directoryIterationHandle = RtBeginIterateDirectory(directoryPath.Chars());
25 const char* filePath = RtGetNextFilePath(directoryIterationHandle);
26 while (filePath != null)
27 {
28 files.Add(filePath);
29 filePath = RtGetNextFilePath(directoryIterationHandle);
30 }
31 RtEndIterateDirectory(directoryIterationHandle);
32 return files;
33 }
34 public static List<string> GetDirectories(const string& directoryPath)
35 {
36 List<string> directories;
37 int directoryIterationHandle = RtBeginIterateDirectory(directoryPath.Chars());
38 const char* dirPath = RtGetNextDirectoryPath(directoryIterationHandle);
39 while (dirPath != null)
40 {
41 directories.Add(dirPath);
42 dirPath = RtGetNextDirectoryPath(directoryIterationHandle);
43 }
44 RtEndIterateDirectory(directoryIterationHandle);
45 return directories;
46 }
47 }
48 }