kvisc/ka/usr/cmd-fsmisc.k

61 lines
1.0 KiB
Plaintext

; The OS/K Team licenses this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
.handle_ERASE:
mov eax, Sys.RemoveFile
mov ax0, q[argv1pos]
bzr ax0, .need_params
trap 0
bltz eax, .couldnt_remove
jmp .handle_MAKE ; re-create it back
.handle_MAKE:
mov eax, Sys.CreateFile
mov ax0, q[argv1pos]
bzr ax0, .need_params
trap 0
bltz eax, .couldnt_open
jmp .print_prompt
.handle_PRINT:
mov eax, Sys.OpenFile
mov ax0, q[argv1pos]
bzr ax0, .need_params
trap 0
bltz eax, .file_not_found
mov ax0, eax
mov ax1, FILE_LOADP
mov ax2, FILE_MAXSZ
mov eax, Sys.ReadFile
trap 0
mov ecx, eax
mov eax, Sys.CloseFile
trap 0
bltz ecx, .couldnt_read
jrcxz .empty_file
call nprint, FILE_LOADP, ecx
jmp .print_prompt
.handle_REMOVE:
mov eax, Sys.RemoveFile
mov ax0, q[argv1pos]
bzr ax0, .need_params
trap 0
bltz eax, .couldnt_remove
jmp .print_prompt