From 08275c406af3e26b35ae036a9afb0879ede7396b Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 20 Nov 2022 22:59:44 +0100 Subject: [PATCH] added chdir/mkdir/rmdir/relabel to cx16diskio --- compiler/res/prog8lib/cx16/cx16diskio.p8 | 41 ++++++++++++++++++++++++ docs/source/todo.rst | 1 - 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/compiler/res/prog8lib/cx16/cx16diskio.p8 b/compiler/res/prog8lib/cx16/cx16diskio.p8 index a0bf1f890..a8e7d9ee4 100644 --- a/compiler/res/prog8lib/cx16/cx16diskio.p8 +++ b/compiler/res/prog8lib/cx16/cx16diskio.p8 @@ -1,6 +1,7 @@ ; Cx16 specific disk drive I/O routines. %import diskio +%import string cx16diskio { @@ -183,4 +184,44 @@ m_in_buffer sta $ffff return total_read } + + sub chdir(ubyte drivenumber, str path) { + ; -- change current directory. + diskio.list_filename[0] = 'c' + diskio.list_filename[1] = 'd' + diskio.list_filename[2] = ':' + void string.copy(path, &diskio.list_filename+3) + void diskio.send_command(drivenumber, diskio.list_filename) + } + + sub mkdir(ubyte drivenumber, str name) { + ; -- make a new subdirectory. + diskio.list_filename[0] = 'm' + diskio.list_filename[1] = 'd' + diskio.list_filename[2] = ':' + void string.copy(name, &diskio.list_filename+3) + void diskio.send_command(drivenumber, diskio.list_filename) + } + + sub rmdir(ubyte drivenumber, str name) { + ; -- remove a subdirectory. + void string.find(name, '*') + if_cs + return ; refuse to act on a wildcard * + diskio.list_filename[0] = 'r' + diskio.list_filename[1] = 'd' + diskio.list_filename[2] = ':' + void string.copy(name, &diskio.list_filename+3) + void diskio.send_command(drivenumber, diskio.list_filename) + } + + sub relabel(ubyte drivenumber, str name) { + ; -- change the disk label. + diskio.list_filename[0] = 'r' + diskio.list_filename[1] = '-' + diskio.list_filename[2] = 'h' + diskio.list_filename[3] = ':' + void string.copy(name, &diskio.list_filename+4) + void diskio.send_command(drivenumber, diskio.list_filename) + } } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 6d1fdfbdb..59fc6a824 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,6 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- add cd/mkdir/rmdir/relabel to cx16diskio - make diskio.list_files not use an internal buffer itself but change names_ptr meaning to user supplied buffer. - ir/vm: allow label in block scope (correct order of block nodes!) - regression test the various projects