unsigned char* bytesFromFile(const char* _path, PathType _type, unsigned int* _size) {

    std::string resourcePath = s_resourceRoot + _path;

    switch (_type) {
    case PathType::absolute:
        return bytesFromFileSystem(_path, _size);
    case PathType::internal:
        return bytesFromAssetManager(_path, _size);
    case PathType::resource:
        if (s_useInternalResources) {
            return bytesFromAssetManager(resourcePath.c_str(), _size);
        } else {
            return bytesFromFileSystem(resourcePath.c_str(), _size);
        }
    }

}
Exemple #2
0
std::vector<char> Platform::bytesFromFile(const char* _path) const {
    if (!_path || strlen(_path) == 0) { return {}; }

    std::vector<char> data;

    auto allocator = [&](size_t size) {
        data.resize(size);
        return data.data();
    };

    bytesFromFileSystem(_path, allocator);

    return data;
}
Exemple #3
0
std::string Platform::stringFromFile(const char* _path) const {
    std::string out;
    if (!_path || strlen(_path) == 0) { return out; }

    std::string data;

    auto allocator = [&](size_t size) {
        data.resize(size);
        return &data[0];
    };

    bytesFromFileSystem(_path, allocator);

    return data;
}