-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also pushed other half of system::fs rename
- Loading branch information
Showing
3 changed files
with
15 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
import system::(io, directfs, async) | ||
import system::(io, fs, async) | ||
import std::(to_string, to_uint, inspect) | ||
|
||
const folder_view := \path. \next. do{ | ||
cps println $ "Contents of " ++ directfs::os_print path; | ||
cps entries = async::block_on $ directfs::read_dir path; | ||
cps println $ "Contents of " ++ fs::os_print path; | ||
cps entries = async::block_on $ fs::read_dir path; | ||
cps list::enumerate entries | ||
|> list::map (pass \id. pass \name. \is_dir. | ||
println $ to_string id ++ ": " ++ directfs::os_print name ++ if is_dir then "/" else "" | ||
println $ to_string id ++ ": " ++ fs::os_print name ++ if is_dir then "/" else "" | ||
) | ||
|> list::chain; | ||
cps print "select an entry, or .. to move up: "; | ||
cps choice = readln; | ||
if (choice == "..") then do { | ||
let parent_path = directfs::pop_path path | ||
let parent_path = fs::pop_path path | ||
|> option::unwrap | ||
|> tuple::pick 0 2; | ||
next parent_path | ||
} else do { | ||
cps subname, is_dir = to_uint choice | ||
|> (list::get entries) | ||
|> option::unwrap; | ||
let subpath = directfs::join_paths path subname; | ||
let subpath = fs::join_paths path subname; | ||
if is_dir then next subpath | ||
else do { | ||
cps file = async::block_on $ directfs::read_file subpath; | ||
cps file = async::block_on $ fs::read_file subpath; | ||
cps contents = async::block_on $ io::read_string file; | ||
cps println contents; | ||
next path | ||
} | ||
} | ||
} | ||
|
||
const main := loop_over (path = directfs::cwd) { | ||
const main := loop_over (path = fs::cwd) { | ||
cps path = folder_view path; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters