Hi All,
I Try to use dos lib to open to read/write files.
I have made some functions for this but I encounter some problems.
Here are the functions :
FILE *FileChannel[ 256 ];
void DEFileOpenToRead( int ChannelID, const char *FileName ){
int FOpened = DEFileOpened( ChannelID );
if ( FOpened == 0 ){
if ( ChannelID > 0 ){
if ( ChannelID < 257 ){
FileChannel[ ChannelID ] = Open( FileName, MODE_OLDFILE );
}
}
}
}
void DEFileOpenToWrite( int ChannelID, const char *FileName ){
int FOpened = DEFileOpened( ChannelID );
if ( FOpened == 0 ){
if ( ChannelID > 0 ){
if ( ChannelID < 257 ){
FileChannel[ ChannelID ] = Open( FileName, MODE_NEWFILE );
}
}
}
}
void DECloseFile( int ChannelID ){
int FOpened = DEFileOpened( ChannelID );
if ( FOpened == 1 ){
Close( FileChannel[ ChannelID ] );
FileChannel[ ChannelID ] = NULL;
}
}
void DEMakeMemblockFromFileEx( int MemblockID, const char *FileName ){
int ChannelID = DENextFreeFile();
DEFileOpenToRead( ChannelID, FileName );
int FileSize = IDOS->GetFileSize( FileChannel[ ChannelID ] );
DEMakeMemblock( MemblockID, FileSize );
IDOS->FRead( FileChannel[ ChannelID ], DEGetMemblockPTR( MemblockID ), FileSize, 1 );
DECloseFile( ChannelID );
}
Concerning Open / Close, I get errors on compilations :
undefined reference to 'close'
undefined reference to 'open'
if I try to change this by :
if I change with IDOS->Open, I get warning :
PAssing argument 2 of 'IDOS->Close' makes integer from pointer without a cast ) ...
Arg 2 is not a pointer ... strange ?
Of course, I have <proto/dos.h> included ;)
and GetFileSize and FRead are correctly identified and does not report any error on compilation.
Don't mind .. I have checked the sample in AmigaOS 4 SDK and founded what was wrong :p
Kindest Regards,
Fred