PhysFS++ is a C++ wrapper for the PhysicsFS library.

Overview

PhysFS++

PhysFS++ is a C++ wrapper for the excellent PhysicsFS library by Ryan C. Gordon and others.

It is licensed under the zlib license - same as PhysicsFS (at the time of writing).

Requirements

CMake for building, and, of course, the PhysicsFS library.

Features

The wrapper simply wraps most functions in a PhysFS namespace, and gives them C++ signatures (std::string rather than const char *).

Additionally:

  • Functions that are related to byte order conversions are placed in the PhysFS::Util namespace.
  • Instead of replicating PHYSFS_openRead, PHYSFS_openWrite, and PHYSFS_openAppend, files are opened as streams using PhysFS::ifstream and PhysFS::ofstream.
  • ofstream's constructor takes a mode, which specifies either append or write.
  • Both ifstream and ofstream are standard streams, and only have an extra method - length, which calls PHYSFS_fileLength.
You might also like...
Simple data packing library (written in C99)

Features Compressed file pack creation Runtime file pack reading Supported operating systems Ubuntu MacOS Windows Build requirements C99 compiler CMak

A simple C library implementing the compression algorithm for isosceles triangles.

orvaenting Summary A simple C library implementing the compression algorithm for isosceles triangles. License This project's license is GPL 2 (as of J

Advanced DXTc texture compression and transcoding library

crunch/crnlib v1.04 - Advanced DXTn texture compression library Public Domain - Please see license.txt. Portions of this software make use of public d

✔️The smallest header-only GUI library(4 KLOC) for all platforms
✔️The smallest header-only GUI library(4 KLOC) for all platforms

Welcome to GUI-lite The smallest header-only GUI library (4 KLOC) for all platforms. 中文 Lightweight ✂️ Small: 4,000+ lines of C++ code, zero dependenc

Integrate PhysFS with raylib, allowing to load images, audio and fonts from data archives.

raylib-physfs Integrate the virtual file system PhysicsFS with raylib, allowing to load images, audio, and fonts from data archives. Features Load the

PhysicsFS; a portable, flexible file i/o abstraction.

PhysicsFS; a portable, flexible file i/o abstraction.

Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!

Do you have a question that doesn't require you to open an issue? Join the gitter channel. If you use uvw and you want to say thanks or support the pr

Wrapper library for the BSD sockets API with a nicer C99 interface

A wrapper library for the BSD sockets API. Why? This library trades the series of getaddrinfo, socket, connect, bind, listen, etc. functions and their

The Ultimate Raylib gaming library wrapper for Nim
The Ultimate Raylib gaming library wrapper for Nim

NimraylibNow! - The Ultimate Raylib wrapper for Nim The most idiomatic and up-to-date wrapper for Raylib gaming C library. Use this library if you wan

Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!

Do you have a question that doesn't require you to open an issue? Join the gitter channel. If you use uvw and you want to say thanks or support the pr

WinINet wrapper - tiny windows HTTPS library, no dependencies.
WinINet wrapper - tiny windows HTTPS library, no dependencies.

WNetWrap A tiny, dependency-free wrapper around WinINet for developers targeting Windows only, who need a lightweight native solution. Inspired by the

A convenience C++ wrapper library for JSON-Glib providing friendly syntactic sugar for parsing JSON

This library is a wrapper for the json-glib library that aims to provide the user with a trivial alternative API to the API provided by the base json-

A C++ wrapper library for the monome serialosc protocol

serialoscpp A C++ wrapper library for the monome serialosc protocol Credits oscpack: Ross Bencina http://www.rossbencina.com/code/oscpack serialosc: 2

C++11 wrapper for the LMDB embedded B+ tree database library.

lmdb++: a C++11 wrapper for LMDB This is a comprehensive C++ wrapper for the LMDB embedded database library, offering both an error-checked procedural

Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable executables. Has a modern C++ wrapper.

memscan Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable

A single file C++ header-only minizip wrapper library

cpp-zipper A single file C++ header-only minizip wrapper library This code is based on 'Making MiniZip Easier to Use' by John Schember. https://nachti

DarkHelp - C++ wrapper library for Darknet
DarkHelp - C++ wrapper library for Darknet

What is the DarkHelp C++ API? The DarkHelp C++ API is a wrapper to make it easier to use the Darknet neural network framework within a C++ application

C++11 wrapper for the LMDB embedded B+ tree database library.

lmdb++: a C++11 wrapper for LMDB This is a comprehensive C++ wrapper for the LMDB embedded database library, offering both an error-checked procedural

The C++14 wrapper around sqlite library

sqlite modern cpp wrapper This library is a lightweight modern wrapper around sqlite C api . #includeiostream #include sqlite_modern_cpp.h using n

Comments
  • The put pointers are not being reset correctly on calls to overflow() and sync()

    The put pointers are not being reset correctly on calls to overflow() and sync()

    If data is larger than the buffer size, then what happens is that the first set of buffered data (2048 bytes) is written over and over again until the entire length of input data has been processed.

    For instance, 500KB input data would result in an output file that is around a gigabytes in size.

    These changes to class fbuf should fix the issue:

        int_type overflow(int_type c = traits_type::eof()) override
        {
            // Write buffer
            if (flush() < 0)
            {
                return traits_type::eof();
            }
    
            setp(buffer, buffer + bufferSize); // reset the put pointers
    
            if (c != traits_type::eof()) 
            {
                *pptr() = (char)c; // Add the overflow character to the put buffer
                pbump(1); // increment the put pointer by one
            }
    
            return c;
        }
    
        int sync() override
        {
            const auto result = flush();
            setp(buffer, buffer + bufferSize); // reset the put pointers
    
            return result;
        }
    
        int flush() const
        {
            const auto len = pptr() - pbase();
            if (len == 0)
            {
                return 0;  // nothing to do
            }
    
            if (PHYSFS_writeBytes(file, pbase(), len) < len)
            {
                return -1;
            }
    
            return 0;
        }
    
    ...
        ~fbuf() override
        {
            flush();
            delete[] buffer;
        }
    
    opened by rh101 0
  • Use c-tor and d-tor for init and deinit

    Use c-tor and d-tor for init and deinit

    I'm aware that PhysicsFS runs sort of "globally" and can be implemented with just static functions, but wouldn't it make sense to bind the init and deinit to the constructor/destructor?

    At least that way one wouldn't have to care about calling both functions and just creates an instance.

    opened by eXpl0it3r 0
  • Exception handling doesn't work

    Exception handling doesn't work

    Given code like this where the file doesn't exist:

    try {
        PhysFS::ifstream file ("filename.txt");
    } catch (std::invalid_argument e) {
        //do something here
    }
    

    A bad access error will crash the program.

    If I remove the exception handling, then it correctly shows the unhanded exception of:

    throw std::invalid_argument("file not found: " + std::string(filename));
    
    opened by SirNerdBear 2
Owner
Kevin Howell
Kevin Howell
A C++ static library offering a clean and simple interface to the 7-zip DLLs.

bit7z A C++ static library offering a clean and simple interface to the 7-zip DLLs Supported Features • Getting Started • Download • Requirements • Bu

Riccardo 294 Sep 13, 2022
Multi-format archive and compression library

Welcome to libarchive! The libarchive project develops a portable, efficient C library that can read and write streaming archives in a variety of form

null 1.8k Sep 24, 2022
LZFSE compression library and command line tool

LZFSE This is a reference C implementation of the LZFSE compressor introduced in the Compression library with OS X 10.11 and iOS 9. LZFSE is a Lempel-

null 1.7k Sep 22, 2022
miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz

Miniz Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951

Rich Geldreich 1.6k Sep 21, 2022
Fork of the popular zip manipulation library found in the zlib distribution.

minizip-ng 3.0.0 minizip-ng is a zip manipulation library written in C that is supported on Windows, macOS, and Linux. Developed and maintained by Nat

zlib-ng 943 Sep 21, 2022
Small strings compression library

SMAZ - compression for very small strings ----------------------------------------- Smaz is a simple compression library suitable for compressing ver

Salvatore Sanfilippo 1k Sep 16, 2022
A massively spiffy yet delicately unobtrusive compression library.

ZLIB DATA COMPRESSION LIBRARY zlib 1.2.11 is a general purpose data compression library. All the code is thread safe. The data format used by the z

Mark Adler 3.8k Sep 25, 2022
Fork of the popular zip manipulation library found in the zlib distribution.

minizip-ng 3.0.1 minizip-ng is a zip manipulation library written in C that is supported on Windows, macOS, and Linux. Developed and maintained by Nat

zlib-ng 943 Sep 21, 2022
An embedded-friendly library for decompressing files from zip archives

An 'embedded-friendly' (aka Arduino) library to extract and decompress files from ZIP archives

Larry Bank 25 Jul 17, 2022
Gzip header-only C++ library

Gzip C++ lib for gzip compression and decompression. Extracted from mapnik-vector-tile for light-weight modularity. Usage // Include the specific gzip

Mapbox 234 Sep 16, 2022