something i am doing wrong or an SAS 6.51 streams problem?

something i am doing wrong or an SAS 6.51 streams problem?

Post by Richard Hob » Wed, 21 Aug 1996 04:00:00



Hi,

I heard that there are some of the people that support(ed) SASC here,
so i thought that this might be a good place for this...

I am porting some code over from a UNIX box which does not seem to be
working on the Amiga.

The general scenario is that there is a class called database which
uses a binary tree data structure and this is the top of the function
that should open a file and read it into the structure:

int database::file_open(ifstream &file, node *& root1)
{
        if (!file)
                return 0;               //file would not open - eject!

        file.seekg(0, ios::end);         //goto end of file
        int eofile = file.tellg();               //find size of file.

        etc...

the problem is that eofile is always coming back as 0 (when i know the
file is much larger).  This code works fine with gcc and visual c.  Is
this likely to be a difference in the Amiga implementation, a bug in
my code, or a problem with SAS?

Many thanks,

        Rick.

 
 
 

something i am doing wrong or an SAS 6.51 streams problem?

Post by sekrue » Thu, 22 Aug 1996 04:00:00



>        int eofile = file.tellg();               //find size of file.
>the problem is that eofile is always coming back as 0 (when i know the
>file is much larger).

This is a bug in the SAS/C streampos. I will include a fix in 6.57,
but until then, you can try a a simple change to iostream.h which will
fix the problem.

Change this code on line 57 of CXXINCLUDE:iostream.h

      operator long()
        _INLINE_FUNC(
          // treat it as an offset, even if it's not.
          {
          return _offset;
          }
        )

to

      operator long()
          // treat it as an offset, even if it's not.
          {
          return _offset + _fpos;
          }

Note: Removing the _INLINE_FUNC() will insure that this version
      will be used instead of the version in sc.lib, for both
      debug, and optimized compiles. Normally, the library version
      is used for debug compiles.

 
 
 

something i am doing wrong or an SAS 6.51 streams problem?

Post by Doug Walk » Fri, 23 Aug 1996 04:00:00


|> The general scenario is that there is a class called database which
|> uses a binary tree data structure and this is the top of the function
|> that should open a file and read it into the structure:
|>
|> int database::file_open(ifstream &file, node *& root1)
|> {
|>         if (!file)
|>                 return 0;               //file would not open - eject!
|>
|>         file.seekg(0, ios::end);         //goto end of file
|>         int eofile = file.tellg();               //find size of file.

Steve Krueger already reported a workaround for this, but here is
the response from Gavin Koch, one of our C++ experts and a member
of the ANSI C++ committee:

Quote:> You can't get the size of a file this way using SAS/C++'s library.
> Whether it's a bug or not is a much more complicated question.  
> Basically SAS/C++ uses pos_t's for tracking positions in files, rather
> than offsets.  Most implementations use offsets (or implement pos_t's
> as offsets).  If you're not sure about the difference between pos_t's and
> offsets you can look them up in any (good) ANSI-C manual.  It's a valid
> ANSI-C++ implementation, and has the advantage that you can seek in HUGE
> files, but has the disadvantage that it ain't what other implementations
> did, and does not support getting the size of a file by seeking to the
> end.  The implementation choice was required for the 370, but probably
> was not the best for the Amiga.

> There is no *ANSI* portable way to get the size of a file (without
> reading the whole file and counting :-) ).  On the Amiga (using SAS/C)
> you may have to get the file handle out of the stream, and ask the OS
> how big the file is.  I don't know the Amiga that well any more, there
> may be an easier way.

--

 *|_o_o|\\     Oompah musician and Schuhplattlerer!
 *|. o.| ||    
  | o  |//     http://www.webbuild.com/~djwalker
  ======
  Ein Prosit Der Gemuetlichkeit!
 
 
 

something i am doing wrong or an SAS 6.51 streams problem?

Post by Richard Hob » Fri, 23 Aug 1996 04:00:00




Quote:>>the problem is that eofile is always coming back as 0 (when i know the
>>file is much larger).

>This is a bug in the SAS/C streampos. I will include a fix in 6.57,
>but until then, you can try a a simple change to iostream.h which will
>fix the problem.

many thanks,

        Rick.

 
 
 

1. Am I doing something wrong?

I am trying to set up my A2000 with 2 2091 controllers simultaneously, but it
doesn't seem to work.  When I get my GVP G-Force 040 Combo back from repairs,
I want to connect my Zip drive and CDRom to my 2091, and connect my 2 1-gig
Quantums to the G-Force card. When I got my 040, I had about 1 hour of use
before it went down, but I had enough time to notice that when I had the zip
connected to the external scsi connector, the 2000 would not boot. I always
had the solid green scsi light which usually indicates a scsi lockup. So, I
figured that since I already had a 2091 controller and it worked well I would
just use the 2091 for the zip and cdrom.  Having 2 2000's I was able to try
the 2nd 2091 simultaneously with the one already in the 2000 now, but the zip
does  not seem to get recognized when connected to the 2nd 2091.
Must I do something different, connect something to the second 2091 <like
connect the scsi cable from the first to the second 2091>??
I would like to sort this out quickly so that when I get back my 040 card I
can use my zip......I'm lost without it.
If I could learn the secret of connecting the zip to the 040 without the 2nd
controller, that would be much better.


2. Canon 4200 error 1002

3. SAS/C 6.50 -> 6.51 patch, or am I an idiot?

4. Participate in Biennale Symposium via the Internet

5. FPU: What am I doing wrong???

6. Palm 3x soft reset when connecting to ISP

7. SAS-C 6.51 problems with local vars

8. hotmail and net passport

9. Problem with SAS/C 6.51

10. Hey, __AMIGADATE__ problems!?? (sas 6.51)

11. SAS/C 6.51 const keyword problem

12. SAS 6.51 CPR Problem ?

13. What am I doing wrong