Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override c library file functions?

Tags:

c++

c

file

stdio

I am working on a game, and one of the requirements per the licence agreement of the sound assets I am using is that they be distributed in a way that makes them inaccessible to the end user. So, I am thinking about aggregating them into a flat file, encrypting them, or some such. The problem is that the sound library I am using (Hekkus Sound System) only accepts a 'char*' file path and handles file reading internally. So, if I am to continue to use it, I will have to override the c stdio file functions to handle encryption or whatever I decide to do. This seems doable, but it worries me. Looking on the web I am seeing people running into strange frustrating problems doing this on platforms I am concerned with(Win32, Android and iOS).

Does there happen to be a cross-platform library out there that takes care of this? Is there a better approach entirely you would recommend?

like image 257
Vigabrand Avatar asked Sep 03 '13 16:09

Vigabrand


1 Answers

Do you have the option of using a named pipe instead of an ordinary file? If so, you can present the pipe to the sound library as the file to read from, and you can decrypt your data and write it to the pipe, no problem. (See Beej's Guide for an explanation of named pipes.)

like image 82
This isn't my real name Avatar answered Oct 20 '22 16:10

This isn't my real name