Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions csharp/Ice/Filesystem/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@

// Recursively list the contents of the root directory.
Console.WriteLine("Contents of root directory:");
ListRecursive(rootDir);
await ListRecursiveAsync(rootDir);

/// <summary>Recursively print the contents of a directory in tree fashion. For files, show the contents of each file.
/// </summary>
/// <param name="dir">The directory to list./<param>
/// <param name="depth">The current nesting level (for indentation).</param>
void ListRecursive(DirectoryPrx dir, int depth = 0)
async Task ListRecursiveAsync(DirectoryPrx dir, int depth = 0)
{
var indent = new string('\t', ++depth);

NodePrx?[] contents = dir.List();
NodePrx?[] contents = await dir.ListAsync();

foreach (NodePrx? node in contents)
{
Debug.Assert(node is not null); // The node proxies returned by list() are never null.

DirectoryPrx? subdir = DirectoryPrxHelper.checkedCast(node);
DirectoryPrx? subdir = await DirectoryPrxHelper.checkedCastAsync(node);
string kind = subdir is not null ? "directory" : "file";
string nodeName = await node.NameAsync();

Console.WriteLine($"{indent}{node.Name()} {kind}:");
Console.WriteLine($"{indent}{nodeName} {kind}:");

if (subdir is not null)
{
ListRecursive(subdir, depth);
await ListRecursiveAsync(subdir, depth);
}
else
{
FilePrx file = FilePrxHelper.uncheckedCast(node);
string[] lines = file.Read();
string[] lines = await file.ReadAsync();
foreach (string line in lines)
{
Console.WriteLine($"{indent}\t{line}");
Expand Down
Loading