[physfs] Packaging programs using PhysFS + ...
Ryan C. Gordon
icculus at clutteredmind.org
Tue May 13 13:07:58 EDT 2003
On 13 May 2003, Gaetan de Menten wrote:
> I'm using physfs in a game but since physfs is not that well-known, it
> seems like binary packages for it are not widespread. Even on the
> official page, the binaries are out of date. As I don't want my users
> to have to compile the library themselves, what should I do? "Copy"
> its source in my source tree (in a subdirectory) and statically link
> to it? or build those binary packages myself and distribute them "on
> the same page" as my game?
Currently, your best bet would be to include the physfs shared library
with your app and not concern yourself with what the user has installed.
I'm considering changing the license to something like the BSD license,
which would allow static linking.
> While I'm at it... I hope it'll be included in SDL2.0... Any hope for
> One more thing:
> It would be nice (and easy to do) to have a function returning the
> number of files in a directory and another one to read a "text" line
> (read until a \n).
Untested code follows:
int numFilesInDir(const char *dirName)
char **rc = PHYSFS_enumerateFiles(dirName);
int retval = 0;
for (i = rc; *i != NULL; i++)
// This will return empty lines if you've got DOS-style "\r\n" endlines!
// extra credit for handling buffer overflows and EOF more gracefully.
void readOneLine(PHYSFS_file *f, char *buf, int bufsize)
int total = 0;
bufsize--; /* allow for null terminating char */
while ((total < bufsize) && (PHYSFS_read(f, buf, 1, 1) == 1))
if ((*buf == '\r') || (*buf == '\n'))
*buf = '\0'; // null terminate it.
More information about the physfs