Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: PhysFS archive stream - more than 4Gb files ?  (Read 5233 times)

0 Members and 1 Guest are viewing this topic.

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
PhysFS archive stream - more than 4Gb files ?
« on: August 17, 2015, 09:09:15 am »
At PhysFS read function we have >>

PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle, void *buffer,
                          PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
{
    FileHandle *fh = (FileHandle *) handle;

    BAIL_IF_MACRO(!fh->forReading, ERR_FILE_ALREADY_OPEN_W, -1);
    BAIL_IF_MACRO(objSize == 0, NULL, 0);
    BAIL_IF_MACRO(objCount == 0, NULL, 0);
    if (fh->buffer != NULL)
        return(doBufferedRead(fh, buffer, objSize, objCount));

    return(fh->funcs->read(fh->opaque, buffer, objSize, objCount));
} /* PHYSFS_read */

At wiki we have >>
https://github.com/SFML/SFML/wiki/Source:-PhysicsFS-Input-Stream
virtual sf::Int64 read(void* data, sf::Int64 size)
{
    if (!isOpen())
        return -1;

    // PHYSFS_read returns the number of 'objects' read or -1 on error.
    // We assume our objects are single bytes and request to read size
    // amount of them.
    return PHYSFS_read(m_File, data, 1, static_cast<PHYSFS_uint32>(size));
}

Ok It say to me - I request read from ZIP archive my 5.5Gb file, but I read only 4Gb (4 294 967 295 bytes) or some wrong size.
How to fix it ??
Any append read functions to buffer ?
And also need for every byte read..
« Last Edit: August 17, 2015, 01:22:06 pm by Redee »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: PhysFS archive stream - more then 4Gb files ?
« Reply #1 on: August 17, 2015, 09:13:06 am »
I'd say that

while (...)
{
    PHYSFS_read(...)
    // advance pointer, decrease size
}

... instead of a single call should do the job.
Laurent Gomila - SFML developer

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: PhysFS archive stream - more then 4Gb files ?
« Reply #2 on: August 17, 2015, 09:14:59 am »
Any simple code example ?

Maybe its no matter because maximum array length to store at x86 OS's is 4bytes = 32bits = (unsigned int) = 4 294 967 295.
Ok, but no need store size at Int64.
Otherwise for x64 systems store at Uint64.

And conclusion is > need 2 ways overloaded functions with size variables Uint32 (x86) and Uint64 (x64).
Using PhysFS there for every byte reading only 1st way = Uint32.

I mean about provide Absract classes - InputStream_x86 and InputStream_x64. But its seems no perfect solution ).
« Last Edit: August 17, 2015, 10:23:11 am by Redee »

maly

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: PhysFS archive stream - more then 4Gb files ?
« Reply #3 on: August 17, 2015, 09:57:41 am »
PHYSFS_readBytes

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: PhysFS archive stream - more then 4Gb files ?
« Reply #4 on: August 17, 2015, 10:18:19 am »
PHYSFS_readBytes
No enable this function - only PHYSFS_read.

Okay, we cat write buffers about 4Gb - **CRAZY** if this need and read portions of Data like this >>
#include <iostream>
using namespace std;
// need build and link PhysFS !!
#include "physfs.h"

void main()
{
        PHYSFS_init(0);
        PHYSFS_addToSearchPath("test.zip", 1);

        // for example we have test.txt with txt > 2345678
        PHYSFS_file* myfile = PHYSFS_openRead("test.txt");
        PHYSFS_sint64 file_size = PHYSFS_fileLength(myfile);

        // 7
        cout << file_size << endl;
        unsigned partSze = 2;
       
        //

        char *myBuf;
        myBuf = new char[ partSze ];

        PHYSFS_uint64 pos = 1;
        unsigned readSze = 3;

        // change start position of fileHandle to second char
        PHYSFS_seek(myfile, pos);
        // and read 3 chars
        PHYSFS_sint64 length_read = PHYSFS_read( myfile, myBuf, 1, readSze );
        PHYSFS_close(myfile);

        //

        // 345
        cout << myBuf << endl;
        delete[] myBuf;

        PHYSFS_deinit();
}
« Last Edit: August 17, 2015, 01:42:28 pm by Redee »

 

anything