Esempio n. 1
0
static int graphics_AndroidTextureReader(void* buffer, size_t bytes, void* userdata) {
    SDL_RWops* ops = (SDL_RWops*)userdata;
#ifndef NOTHREADEDSDLRW
    int i = ops->read(ops, buffer, 1, bytes);
#else
    // workaround for http:// bugzilla.libsdl.org/show_bug.cgi?id=1422
    int i = main_NoThreadedRWopsRead(ops, buffer, 1, bytes);
#endif
    return i;
}
Esempio n. 2
0
void AddResource(ResourceManager resourceManager, std::string identifier, ResourceType resourceType) {
    ResourceHandle resourceHandle = CreateResourceHandle(resourceType);

    switch (resourceType) {
    case TEXTURE: {
        std::string strId =  resourceManager->assetBaseDir + identifier;
        resourceHandle->textureRes->texture = IMG_LoadTexture(resourceManager->renderer, strId.c_str());
        if(!resourceHandle->textureRes->texture) {
            LOGE("Unable to load resource: %s\n", strId.c_str());
            FreeResourceHandle(resourceManager, resourceHandle);
            assert(0);
        }
        resourceHandle->textureRes->name = identifier; }
        break;
    case TMX_MAP: {
        std::string strId = resourceManager->assetBaseDir + identifier;
        resourceHandle->tmxMapResource->map.ParseFile(strId);
        break;
    }
    case ENTITY: {
        std::string strId = resourceManager->assetBaseDir + identifier;
        SDL_RWops * file = SDL_RWFromFile (strId.c_str(), "rb");

        if (!file) {
            assert(0);
        }

        int fileSize = file->size(file);

        if (fileSize <= 0) {
            assert(0);
        }

        char* fileText = new char[fileSize + 1];
        fileText[fileSize] = 0;
        file->read(file, fileText, 1, fileSize);

        file->close(file);

        std::string text(fileText, fileText+fileSize);
        delete [] fileText;

        resourceHandle->entityTemplateResource->xml.Parse(text.c_str());

        break;
    }
    default:
        assert(0);
    }

    resourceManager->resources[identifier] = resourceHandle;
}
Esempio n. 3
0
std::string LoadAllText(std::string file)
{
	SDL_RWops *rw = SDL_RWFromFile(file.c_str(), "r");

	auto size = rw->size(rw);
	char* script = new char[size + 1];
	memset(script, 0, size + 1);
	rw->read(rw, script, sizeof(char), size);
	rw->close(rw);

	std::string result = script;
	delete[] script;

	return result;
}
Esempio n. 4
0
void Purity::LuaManager::doFile(const std::string& luaFileName)
{
    SDL_RWops* file = SDL_RWFromFile(luaFileName.c_str(), "rb");

    int fileSize = file->size(file);
    char* fileContents = new char[fileSize + 1];

    file->read(file, fileContents, 1, fileSize);
    fileContents[fileSize] = '\0';

    file->close(file);

    luaL_dostring(mLuaState, fileContents);

    delete [] fileContents;
}
Esempio n. 5
0
void Purity::Font::loadFont()
{
    SDL_RWops* fontFile = SDL_RWFromFile(mFontFileName.c_str(), "rb");

    if (fontFile == nullptr)
    {
        std::cerr << "Error loading font file"
                  << ": " << SDL_GetError() << std::endl;
    }

    const auto fontFileSize = fontFile->size(fontFile);
    mFontData.reserve(fontFileSize);

    fontFile->read(fontFile, &mFontData[0], 1, fontFileSize);

    fontFile->close(fontFile);
}
Esempio n. 6
0
File: io.c Progetto: mbelicki/warp
extern warp_result_t read_file(const char *path, warp_array_t *out_buffer) {
    SDL_RWops *io = SDL_RWFromFile(path, "r");
    if (io == NULL) {
        return warp_failure("Cannot open the file: %s.", path);
    }
    Sint64 size = io->size(io);
    char *content = malloc(sizeof (char) * (size + 1));
    if (content == NULL) {
        io->close(io);
        return warp_failure("Cannot allocate file buffer for file: %s", path);
    }
    if (io->read(io, content, size, 1) == 0) {
        free(content);
        io->close(io);
        return warp_failure("Error while reading file: %s.", path);
    }
    io->close(io);

    content[size] = '\0';
    *out_buffer = warp_array_create_from_buffer(content, sizeof (char), size + 1, NULL);
    free(content);

    return warp_success();
}
Esempio n. 7
0
void
APKProtocol::load()
{
    auto resolvedFilename = this->resolvedFilename();

    auto options = _options;

    auto protocolPrefixPosition = resolvedFilename.find("://");

    if (protocolPrefixPosition != std::string::npos)
    {
        resolvedFilename = resolvedFilename.substr(protocolPrefixPosition + 3);
    }

    if (resolvedFilename.find("./") == 0u)
    {
        resolvedFilename = resolvedFilename.substr(2u);
    }

    _options = options;

    SDL_RWops* file = SDL_RWFromFile(resolvedFilename.c_str(), "rb");

    auto loader = shared_from_this();

    if (file)
    {
        if (_options->loadAsynchronously() &&
            AbstractCanvas::defaultCanvas() != nullptr &&
            AbstractCanvas::defaultCanvas()->isWorkerRegistered("apk-protocol"))
        {
            file->close(file);

            auto worker = AbstractCanvas::defaultCanvas()->getWorker("apk-protocol");
            auto instance = std::static_pointer_cast<APKProtocol>(shared_from_this());

            _workerSlot = worker->message()->connect(
                [this, instance](async::Worker::Ptr, async::Worker::Message message)
                {
                    if (message.type == "complete")
                    {
                        data().assign(message.data.begin(), message.data.end());

                        complete()->execute(instance);

                        _activeInstances.erase(instance);

                        _workerSlot = nullptr;
                    }
                    else if (message.type == "progress")
                    {
                        // FIXME
                    }
                    else if (message.type == "error")
                    {
                        error()->execute(instance);

                        _activeInstances.erase(instance);

                        _workerSlot = nullptr;
                    }
                }
            );

            auto offset = options->seekingOffset();
            auto length = options->seekedLength();

            std::stringstream inputStream;

            inputStream.write(reinterpret_cast<const char*>(&offset), 4u);
            inputStream.write(reinterpret_cast<const char*>(&length), 4u);
            inputStream.write(resolvedFilename.data(), resolvedFilename.size());

            const auto input = inputStream.str();

            worker->start(std::vector<char>(input.begin(), input.end()));
        }
        else
        {
            auto offset = options->seekingOffset();
            auto size = options->seekedLength() > 0 ? options->seekedLength() : file->size(file);

            _progress->execute(shared_from_this(), 0.0);

            data().resize(size);

            file->seek(file, offset, RW_SEEK_SET);
            file->read(file, (char*) &data()[0], size, 1);
            file->close(file);

            _progress->execute(loader, 1.0);

            _complete->execute(shared_from_this());
        }
    }
    else
    {
        _error->execute(shared_from_this());
    }
}
Esempio n. 8
0
int
main(int argc, char *argv[])
{
    SDL_RWops *rwops = NULL;
    char test_buf[30];

    /* Enable standard application logging */
	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

    cleanup();

/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */

    rwops = SDL_RWFromFile(NULL, NULL);
    if (rwops)
        RWOP_ERR_QUIT(rwops);
    rwops = SDL_RWFromFile(NULL, "ab+");
    if (rwops)
        RWOP_ERR_QUIT(rwops);
    rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj");
    if (rwops)
        RWOP_ERR_QUIT(rwops);
    rwops = SDL_RWFromFile("something", "");
    if (rwops)
        RWOP_ERR_QUIT(rwops);
    rwops = SDL_RWFromFile("something", NULL);
    if (rwops)
        RWOP_ERR_QUIT(rwops);
    SDL_Log("test1 OK\n");

/* test 2 : check that inexistent file is not successfully opened/created when required */
/* modes : r, r+ imply that file MUST exist
   modes : a, a+, w, w+ checks that it succeeds (file may not exists)

 */
    rwops = SDL_RWFromFile(FBASENAME2, "rb");   /* this file doesn't exist that call must fail */
    if (rwops)
        RWOP_ERR_QUIT(rwops);
    rwops = SDL_RWFromFile(FBASENAME2, "rb+");  /* this file doesn't exist that call must fail */
    if (rwops)
        RWOP_ERR_QUIT(rwops);
    rwops = SDL_RWFromFile(FBASENAME2, "wb");
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    rwops->close(rwops);
    unlink(FBASENAME2);
    rwops = SDL_RWFromFile(FBASENAME2, "wb+");
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    rwops->close(rwops);
    unlink(FBASENAME2);
    rwops = SDL_RWFromFile(FBASENAME2, "ab");
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    rwops->close(rwops);
    unlink(FBASENAME2);
    rwops = SDL_RWFromFile(FBASENAME2, "ab+");
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    rwops->close(rwops);
    unlink(FBASENAME2);
    SDL_Log("test2 OK\n");

/* test 3 : creation, writing , reading, seeking,
            test : w mode, r mode, w+ mode
 */
    rwops = SDL_RWFromFile(FBASENAME1, "wb");   /* write only */
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    if (1 != rwops->write(rwops, "1234567890", 10, 1))
        RWOP_ERR_QUIT(rwops);
    if (10 != rwops->write(rwops, "1234567890", 1, 10))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->write(rwops, "1234567", 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);   /* we are in write only mode */
    rwops->close(rwops);

    rwops = SDL_RWFromFile(FBASENAME1, "rb");   /* read mode, file must exists */
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);
    if (20 != rwops->seek(rwops, -7, RW_SEEK_END))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->read(rwops, test_buf, 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "1234567", 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 10, 100))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR))
        RWOP_ERR_QUIT(rwops);
    if (2 != rwops->read(rwops, test_buf, 10, 3))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "12345678901234567890", 20))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->write(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);   /* readonly mode */
    rwops->close(rwops);

/* test 3: same with w+ mode */
    rwops = SDL_RWFromFile(FBASENAME1, "wb+");  /* write + read + truncation */
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    if (1 != rwops->write(rwops, "1234567890", 10, 1))
        RWOP_ERR_QUIT(rwops);
    if (10 != rwops->write(rwops, "1234567890", 1, 10))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->write(rwops, "1234567", 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);
    if (1 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);   /* we are in read/write mode */
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);
    if (20 != rwops->seek(rwops, -7, RW_SEEK_END))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->read(rwops, test_buf, 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "1234567", 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 10, 100))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR))
        RWOP_ERR_QUIT(rwops);
    if (2 != rwops->read(rwops, test_buf, 10, 3))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "12345678901234567890", 20))
        RWOP_ERR_QUIT(rwops);
    rwops->close(rwops);
    SDL_Log("test3 OK\n");

/* test 4: same in r+ mode */
    rwops = SDL_RWFromFile(FBASENAME1, "rb+");  /* write + read + file must exists, no truncation */
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    if (1 != rwops->write(rwops, "1234567890", 10, 1))
        RWOP_ERR_QUIT(rwops);
    if (10 != rwops->write(rwops, "1234567890", 1, 10))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->write(rwops, "1234567", 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);
    if (1 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);   /* we are in read/write mode */
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);
    if (20 != rwops->seek(rwops, -7, RW_SEEK_END))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->read(rwops, test_buf, 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "1234567", 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 10, 100))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR))
        RWOP_ERR_QUIT(rwops);
    if (2 != rwops->read(rwops, test_buf, 10, 3))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "12345678901234567890", 20))
        RWOP_ERR_QUIT(rwops);
    rwops->close(rwops);
    SDL_Log("test4 OK\n");

/* test5 : append mode */
    rwops = SDL_RWFromFile(FBASENAME1, "ab+");  /* write + read + append */
    if (!rwops)
        RWOP_ERR_QUIT(rwops);
    if (1 != rwops->write(rwops, "1234567890", 10, 1))
        RWOP_ERR_QUIT(rwops);
    if (10 != rwops->write(rwops, "1234567890", 1, 10))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->write(rwops, "1234567", 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);

    if (1 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);

    if (20 + 27 != rwops->seek(rwops, -7, RW_SEEK_END))
        RWOP_ERR_QUIT(rwops);
    if (7 != rwops->read(rwops, test_buf, 1, 7))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "1234567", 7))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 1, 1))
        RWOP_ERR_QUIT(rwops);
    if (0 != rwops->read(rwops, test_buf, 10, 100))
        RWOP_ERR_QUIT(rwops);

    if (27 != rwops->seek(rwops, -27, RW_SEEK_CUR))
        RWOP_ERR_QUIT(rwops);

    if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
        RWOP_ERR_QUIT(rwops);
    if (3 != rwops->read(rwops, test_buf, 10, 3))
        RWOP_ERR_QUIT(rwops);
    if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30))
        RWOP_ERR_QUIT(rwops);
    rwops->close(rwops);
    SDL_Log("test5 OK\n");
    cleanup();
    return 0;                   /* all ok */
}
Esempio n. 9
0
	void Map::ParseFile(const string &fileName)
	{
		file_name = fileName;

		int lastSlash = fileName.find_last_of("/");

		// Get the directory of the file using substring.
		if (lastSlash > 0)
		{
			file_path = fileName.substr(0, lastSlash + 1);
		}
		else
		{
			file_path = "";
		}

		char* fileText;
		int fileSize;

		// Open the file for reading.
#ifdef USE_SDL2_LOAD
		SDL_RWops * file = SDL_RWFromFile (fileName.c_str(), "rb");
#else
		FILE *file = fopen(fileName.c_str(), "rb");
#endif

		// Check if the file could not be opened.
		if (!file)
		{
			has_error = true;
			error_code = TMX_COULDNT_OPEN;
			error_text = "Could not open the file.";
			return;
		}

		// Find out the file size.
#ifdef USE_SDL2_LOAD
		fileSize = file->size(file);
#else
		fseek(file, 0, SEEK_END);
		fileSize = ftell(file);
		fseek(file, 0, SEEK_SET);
#endif

		// Check if the file size is valid.
		if (fileSize <= 0)
		{
			has_error = true;
			error_code = TMX_INVALID_FILE_SIZE;
			error_text = "The size of the file is invalid.";
			return;
		}

		// Allocate memory for the file and read it into the memory.
		fileText = new char[fileSize + 1];
		fileText[fileSize] = 0;
#ifdef USE_SDL2_LOAD
		file->read(file, fileText, 1, fileSize);
#else
		fread(fileText, 1, fileSize, file);
#endif

#ifdef USE_SDL2_LOAD
		file->close(file);
#else
		fclose(file);
#endif

		// Copy the contents into a C++ string and delete it from memory.
		std::string text(fileText, fileText+fileSize);
		delete [] fileText;

		ParseText(text);
	}
Esempio n. 10
0
int main(int argc, char *argv[])
{
	SDL_RWops *rwops = NULL;
	char test_buf[30];
	
	cleanup();

	
	rwops = SDL_RWFromFile(NULL,NULL);
	if (rwops) RWOP_ERR_QUIT(rwops);
	rwops = SDL_RWFromFile(NULL,"ab+");
	if (rwops) RWOP_ERR_QUIT(rwops);
	rwops = SDL_RWFromFile(NULL,"sldfkjsldkfj");
	if (rwops) RWOP_ERR_QUIT(rwops);
	rwops = SDL_RWFromFile("something","");
	if (rwops) RWOP_ERR_QUIT(rwops);
	rwops = SDL_RWFromFile("something",NULL);
	if (rwops) RWOP_ERR_QUIT(rwops);	
	printf("test1 OK\n");

	rwops = SDL_RWFromFile(FBASENAME2,"rb"); 
	if (rwops) RWOP_ERR_QUIT(rwops);
	rwops = SDL_RWFromFile(FBASENAME2,"rb+"); 
	if (rwops) RWOP_ERR_QUIT(rwops);
	rwops = SDL_RWFromFile(FBASENAME2,"wb");
	if (!rwops) RWOP_ERR_QUIT(rwops); 
	rwops->close(rwops); unlink(FBASENAME2);
	rwops = SDL_RWFromFile(FBASENAME2,"wb+");
	if (!rwops) RWOP_ERR_QUIT(rwops); 
	rwops->close(rwops); unlink(FBASENAME2);
	rwops = SDL_RWFromFile(FBASENAME2,"ab"); 
	if (!rwops) RWOP_ERR_QUIT(rwops); 
	rwops->close(rwops); unlink(FBASENAME2);
	rwops = SDL_RWFromFile(FBASENAME2,"ab+");
	if (!rwops) RWOP_ERR_QUIT(rwops); 
	rwops->close(rwops); unlink(FBASENAME2);
	printf("test2 OK\n");

	rwops = SDL_RWFromFile(FBASENAME1,"wb"); 	
	if (!rwops)											RWOP_ERR_QUIT(rwops);
	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); 
	rwops->close(rwops);

	rwops = SDL_RWFromFile(FBASENAME1,"rb"); 
	if (!rwops)											RWOP_ERR_QUIT(rwops);
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
	if (0!=rwops->write(rwops,test_buf,1,1))			RWOP_ERR_QUIT(rwops); 
	rwops->close(rwops);

	rwops = SDL_RWFromFile(FBASENAME1,"wb+"); 		
	if (!rwops)											RWOP_ERR_QUIT(rwops);
	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); 
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
	rwops->close(rwops);
	printf("test3 OK\n");

	rwops = SDL_RWFromFile(FBASENAME1,"rb+"); 		
	if (!rwops)											RWOP_ERR_QUIT(rwops);
	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); 
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
	rwops->close(rwops);
	printf("test4 OK\n");

	rwops = SDL_RWFromFile(FBASENAME1,"ab+"); 		
	if (!rwops)											RWOP_ERR_QUIT(rwops);
	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops); 	
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	
	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); 
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
	
	if (20+27!=rwops->seek(rwops,-7,RW_SEEK_END))		RWOP_ERR_QUIT(rwops);					
	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
	
	if (27!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);
	
	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);
	if (3!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
	if (SDL_memcmp(test_buf,"123456789012345678901234567123",30))	
														RWOP_ERR_QUIT(rwops);
	rwops->close(rwops);
	printf("test5 OK\n");
	cleanup();
	return 0; 
}