1. Deleting a file
- Posted by Architek <architek at GEOCITIES.COM> Apr 28, 1997
- 938 views
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
2. Re: Deleting a file
- Posted by Lucius L Hilley III <luciuslhilleyiii at JUNO.COM> Apr 30, 1997
- 933 views
On Mon, 28 Apr 1997 19:09:12 -0400 Architek <architek at GEOCITIES.COM> writes: > >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. > > ************************************ > This message sent by Daniel Berstein > ************************************ > email: architek at geocities.com If you are doing it from text mode then you can make your active page, 1 or 2 or something other than your display page which I believe is 0 by default. ONLY problem there is that I believe your error message will pop up on page 0. NOT sure. Check it out. You should have no problem using this with DOS commands such as copy. I am under ver 6.22 of DOS. My del doesn't return anything. unless the file isn't found. You should use: file = "filename.tmp" system("del "& file, 2) OR system("del filename.tmp", 2) Since delete doesn't display anything you can do it under Text or Graphics mode. Hope this helps --Lucius Lamar Hilley III -- E-mail at luciuslhilleyiii at juno.com -- I support transferring of files less than 60K. -- I can Decode both UU and Base64 format.
3. Re: Deleting a file
- Posted by Marcel Kollenaar <M.Kollenaar at SLO.NL> Apr 30, 1997
- 933 views
Architek wrote: I tested your function and got an dosserror 3. It meant that is could not find the path. So I tried it with a path and my file was deleted. Marcel Kollenaar --Code -- include machine.e -- 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 with trace -- 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 trace(1) integer a a = sys_del("c:\\euphoria\\pex\\test.asc")
4. Re: Deleting a file
- Posted by Ad Rienks <Ad_Rienks at COMPUSERVE.COM> Apr 30, 1997
- 939 views
Architek writes: -- snip ----- buff = allocate_low(length(filename)+1) poke(buff,filename) poke(buff+length(filename),0) -------------------------------------------------------- I was wondering if the last line should not read: poke(buff + length(filename) + 1, 0) ^^^^ Am I right or am I right? Hope this helps Ad Rienks
5. Re: Deleting a file
- Posted by Architek <architek at GEOCITIES.COM> Apr 30, 1997
- 936 views
- Last edited May 01, 1997
Ad Rienks wrote: > -- snip ----- > buff = allocate_low(length(filename)+1) > poke(buff,filename) > poke(buff+length(filename),0) > -------------------------------------------------------- > > I was wondering if the last line should not read: > poke(buff + length(filename) + 1, 0) > ^^^^ > Am I right or am I right? I don't thinks so... give them numbers: filename = "myfile" (length = 6) bytes allocated: 6 + 1 = 7 bytes (lets give buff any address: 10 to 16) poke(10,"myfile") ---> pokes bytes 10,11,12,13,14,15 poke(10+6,0) = poke(16,0) --> Which is defenitly the right offset of buff I don't know if you understand my demostration, but if you didn't... the original way is right, you must understand that offsets start from '0'. Thanks anyway, -- ************************************ 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
6. Re: Deleting a file
- Posted by Jacques Deschenes <desja at QUEBECTEL.COM> Apr 30, 1997
- 935 views
- Last edited May 01, 1997
--=====================_862467637==_ At 19:09 97-04-28 -0400, Daniel Berstein wrote: >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-------- I tested it on my computer without any problem. I attached copy.ex which use dos interrupt #21 to copy a file. You need doswrap.e to use it. If you don't have it you can find it on Euphoria Official home page or drop me an e-mail I'll send it to you. --=====================_862467637==_ -- copying file demo. include doswrap.e constant BUFF_SIZE = power(2,15) function CopyFile(sequence Source, sequence Dest) atom buffer integer FSrc, FDest, NbRead, junk FSrc = DosOpen(Source,READ) if FSrc = -1 then return 0 end if FDest = DosCreate(Dest,0) if FDest = -1 then return 0 end if buffer = allocate_low(BUFF_SIZE) if buffer = 0 then return 0 end if NbRead = BlockRead(FSrc,buffer,BUFF_SIZE) while NbRead > 0 do if BlockWrite(FDest,buffer,NbRead) = -1 then junk = DosClose(FSrc) junk = DosClose(FDest) free_low(buffer) return 0 end if NbRead = BlockRead(FSrc,buffer,BUFF_SIZE) end while junk = DosClose(FSrc) junk = DosClose(FDest) free_low(buffer) return 1 end function --=====================_862467637==_ Jacques Deschenes Baie-Comeau, Quebec Canada desja at quebectel.com --=====================_862467637==_--
7. Re: Deleting a file
- Posted by Architek <architek at GEOCITIES.COM> May 01, 1997
- 987 views
Jacques Deschenes wrote: > I tested it on my computer without any problem. Ooops, I made the function OK, but I just realized I was calling it bad... I used '\' instaed of '\\' for the file path :P Stupid thing!!! > I attached copy.ex which use dos interrupt #21 to copy a file. You need > doswrap.e > to use it. If you don't have it you can find it on Euphoria Official home > page or > drop me an e-mail I'll send it to you. Thanks, I got your files. -- ************************************ 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