English Amiga Board Amiga Lore


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 24 August 2017, 21:31   #1
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 42
Posts: 223
Append a file?

It was many years ago I was messing with dos.library so.. Is there a good way of appending a file (68k asm)?
Currently it looks like I have to use Seek() to detect end of file and then write(?) but I hope there's a better way...?
Thanks in advance.
oRBIT is offline  
AdSense AdSense  
Old 24 August 2017, 22:07   #2
jotd
Cat freak
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 46
Posts: 1,888
There are only 3 modes for Open(): MODE_READ, MODE_WRITE and MODE_READWRITE.

AFAIK the only way to append using dos.library is to open the file using MODE_READ or MODE_READWRITE, seek to the end and Write().

I must admit I never did that. When I needed this, I always used a C program and the "a" mode
jotd is offline  
Old 24 August 2017, 22:38   #3
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,526
You cannot write to a file opened with MODE_OLDFILE. (At least you should not expect to be able to.)

MODE_READWRITE is the only legal way to write to an existing file without erasing it. To write to the end of the file you Seek(fh,0,OFFSET_END) and then just Write().
thomas is offline  
Old 24 August 2017, 23:07   #4
jotd
Cat freak
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 46
Posts: 1,888
in my old "dos.guide": if the mode is MODE_OLDFILE, the file is opened in reading and writing.
It also explains that the difference with MODE_READWRITE is that READWRITE creates the file if doesn't exist (OLDFILE doesn't)
jotd is offline  
Old 25 August 2017, 09:00   #5
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,379
Quote:
Originally Posted by thomas View Post
You cannot write to a file opened with MODE_OLDFILE. (At least you should not expect to be able to.)
Never seen anywhere it was illegal to do so

Writing to such a file is perfectly possible but you do not know the file is writeable before you actually try to do it.
meynaf is offline  
Old 25 August 2017, 21:39   #6
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 42
Posts: 223
Quote:
Originally Posted by thomas View Post
You cannot write to a file opened with MODE_OLDFILE. (At least you should not expect to be able to.)

MODE_READWRITE is the only legal way to write to an existing file without erasing it. To write to the end of the file you Seek(fh,0,OFFSET_END) and then just Write().
Thanks this did the trick.
oRBIT is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
asm code file errors and external file locations Brick Nash support.WinUAE 0 06 April 2015 17:14
File .NFO & file ID.diz stuff.... How To..!! DC33 support.Other 4 11 March 2009 10:21
File not executable ancalimon support.WinUAE 8 15 February 2008 17:18
Running non .adf file, .info file?? ypestis New to Emulation or Amiga scene 5 29 March 2006 18:53

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:09.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.24225 seconds with 12 queries