Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
114 user(s) are online (106 user(s) are browsing Forums)

Members: 1
Guests: 113

trixie, more...

Support us!

Headlines

 
  Register To Post  

[Resolved ] IDOS->Read issue.
Quite a regular
Quite a regular


See User information
I have opened a file using :


BPTR FileChannel;
FileChannel = IDOS->Open( FileName, MODE_OLDFILE );

and I read from this file using :

IDOS->Read( FileChannel, MyMemoryPTR, BytesAmount );

The problem I encounter is this one :

- When I read small amount ( BytesAmount is small ie : 256, 144, etc ... ) I work perfectly, it read the file content and move in the file so if I do another IDOS->Read file, it will read what follow the latest read in the file

- When I read large amount ( BytesAmount is bigger ie : 24000, 48000, etc ... ) if I do another read, it will read exactly the same area on the file a second time ... the pointer in the file remain at the same place.

Is this normal ?
Is there a solution to read step by step a file ( by some sort of hunks ) ?

Regards,
AmiDARK.


Edited by freddix on 2010/5/7 16:44:38
All we have to decide is what to do with the time that is given to us.
Go to top
Re: IDOS->Read issue.
Just popping in
Just popping in


See User information
@freddix

IDOS->Read() is not a void function.

IDOS->Read() n'est pas une fonction vide.


Edited by colinw on 2010/5/7 7:47:17
Go to top
Re: IDOS->Read issue.
Quite a regular
Quite a regular


See User information
@colinw
Effectively.

But I'm not sure to understand ( I'm french and I'm not a perfect english speaking person ;) )

If Actual Length < Length I want it to read, should I recall IDOS->Read function ? With same parameters ? With parameters updated to shift APTR* and Length with the values already read by IDOS ?

Regards,
AmiDARK.

All we have to decide is what to do with the time that is given to us.
Go to top
Re: IDOS->Read issue.
Quite a regular
Quite a regular


See User information
@freddix/AmiDark

When you issue the request:
Length = IDOS->Read (FileHandle, BufferPtr, MaxBytes),

DOS will read from the current place in the file, a maximum of MaxBytes. It will store what it reads starting at BufferPtr and returns the number of bytes read in Length. It will then increment the current place in the file by Length.

Obviously if it runs into EOF while reading, Length will be less than MaxBytes.
If you repeat the request with the same parameters, it will read (or try to) the next MaxBytes from the file and store them at the same place (BufferPtr).

You have to check Length (to see how much it read) and if the result is -1, IoErr() (to see if the Read() ran into EOF).

If you need to repeat a Read(), you will have to call IDOS->ChangeFilePosition() to place the internal read pointer at the proper place.

cheers
tony
Go to top
Re: IDOS->Read issue.
Quite a regular
Quite a regular


See User information
@tonyw
Thank you for your answer.

With this function, is it possible to go forward and backward in the file ?

Quote:
You have to check Length (to see how much it read) and if the result is -1, IoErr() (to see if the Read() ran into EOF).

I get -1 but file position is at 1172 and file is approx 1.2Mbytes len ... strange then ?

Regards,
AmiDARK

All we have to decide is what to do with the time that is given to us.
Go to top
Re: IDOS->Read issue.
Home away from home
Home away from home


See User information
@freddix

-1 indicates an error has occured, yiou need to check to see what therror was.

You do this by calling IDOS->IOErr() and checking the value returned.

Go to top
Re: IDOS->Read issue.
Quite a regular
Quite a regular


See User information
@freddix

Quote:

With this function, is it possible to go forward and backward in the file ?

If you mean the IDOS->ChangeFilePosition(), yes, you can directly set the read pointer anywhere within the file, either as an absolute address or as an offset from the current place.

See Andy Broad's response re the -1 error.

cheers
tony
Go to top
Re: IDOS->Read issue.
Quite a regular
Quite a regular


See User information
@all:
Ok. Thank you for these.

I will make my own Read function that'll handle all these specificities from IDOS->Read so I will automate the principle to avoid having to handle this in all functions that'll use IDOS->Read function.

[EDIT]
I've found the solution.
In fact, it did sent error 116 ( Argument missing )
I've checked all info and in fact My memory allocation was not set correctly and pointer was NULL ... that caused IDOS->Read to generate this error.

Now, I've fixed my 3D Object loading function that work perfectly.
I'm working on adding limb rotation/position and new texturing.

Kindest Regards,
AmiDARK


Edited by freddix on 2010/5/7 16:46:38
All we have to decide is what to do with the time that is given to us.
Go to top

  Register To Post

 




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




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project