Deleting a file
Hi, I've got a problem:
I need to delete a file, but don't want to use the system() function,
cause it has to be "transparent" to the user. So I got this bright
idea of using DOS interrupts (#21). At the end is the code I used, but
it doesn't work... I keep getting DOS error 2 (file not found) and
5 (access denied). Can anyone tell me what is wrong? Is there any
other way to that?
I also needed to copy a file but I solve that with a loop of getc() and
puts() until an EOF.. is there another eficient way?
Thanks.
-------------CUT HERE--------------
-- SYS_DEL()
-- Uses DOS INT #21, service #41 to delete a file given an ASCIIZ filename
-- Returns 1 if succesfull, else return 0 and displays DOS error code
-- INT reference: HelpPC 2.1
function sys_del(sequence filename)
sequence reg_list
integer buff
buff = allocate_low(length(filename)+1)
poke(buff,filename)
poke(buff+length(filename),0)
reg_list = repeat(0,10)
reg_list[REG_AX] = #4100
reg_list[REG_DS] = floor(buff/16)
reg_list[REG_DX] = remainder(buff,16)
reg_list = dos_interrupt(#21,reg_list)
free_low(buff)
if remainder(reg_list[REG_FLAGS],2) != 0 then
puts(1, "DOS error number :")
print(1,reg_list[REG_AX])
puts(1,"\n")
return 0
else
return 1
end if
end function
--------END OF CODE--------
--
************************************
This message sent by Daniel Berstein
************************************
email: architek at geocities.com
homepages: http://www.geocities.com/SiliconValley/Heights/9316
http://www.cybercity.hko.net/silicon_valley/architek
|
Not Categorized, Please Help
|
|