Mercurial > hg > index.fcgi > lj > lj046-2players
diff src/ljpath.h @ 0:c84446dfb3f5
initial add
author | paulo@localhost |
---|---|
date | Fri, 13 Mar 2009 00:39:12 -0700 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/ljpath.h Fri Mar 13 00:39:12 2009 -0700 1.3 @@ -0,0 +1,74 @@ 1.4 +/* 1.5 +ljpath - functions to support an application that can be 1.6 +installed to either a read-write folder ("portable" config) 1.7 +or to a read-only folder ("installed" config) 1.8 + 1.9 +Copyright 2008 Damian Yerrick 1.10 + 1.11 +Insert zlib license here. 1.12 + 1.13 +*/ 1.14 + 1.15 +#ifndef LJPATH_H 1.16 +#define LJPATH_H 1.17 + 1.18 +#ifdef __cplusplus 1.19 +#include <cstdio> 1.20 +using std::FILE; 1.21 +extern "C" 1.22 +{ 1.23 +#define DISTINCT 1.24 +#else 1.25 +#include <stdio.h> 1.26 +#define DISTINCT restrict 1.27 +#endif 1.28 + 1.29 +/** 1.30 + * Sets up the paths used by ljfopen(). 1.31 + * Determines whether the program is marked as "installed", by 1.32 + * the presence of a file called installed.ini in the folder 1.33 + * containing the executable file. If so, uses a folder in the 1.34 + * user's home directory instead of the current directory for 1.35 + * writable files. 1.36 + * @param argv0 the executable file's path 1.37 + * @return nonzero for installed; zero for portable 1.38 + */ 1.39 +int ljpathInit(const char *argv0); 1.40 + 1.41 +/** 1.42 + * Sets the skin folder to the folder containing a file. For instance, 1.43 + * in a skinnable falling block game, this would be the folder holding 1.44 + * the .skin file that describes the path to each graphic used for the 1.45 + * game display. 1.46 + * @param filename the name of the file 1.47 + */ 1.48 +void ljpathSetSkinFolder(const char *filename); 1.49 + 1.50 +/** 1.51 + * Searches for a file in read-write, skin, and read-only folders 1.52 + * @param dst pointer to a PATH_MAX-byte buffer to hold the path 1.53 + * @param filename the name of the file that will be searched for 1.54 + * @return nonzero if the file was found; 0 if not found 1.55 + */ 1.56 +int ljpathFind_r(char *DISTINCT dst, const char *DISTINCT filename); 1.57 + 1.58 +int ljpathFind_w(char *DISTINCT dst, const char *DISTINCT filename); 1.59 + 1.60 +/** 1.61 + * Searches for a file and opens it. After it is opened, the 1.62 + * caller may use stdio.h operations on it and must close it. 1.63 + * Files being read are searched for using ljpathFind_r; others are 1.64 + * searched for using ljpathFind_r 1.65 + * @param filename the name of the file that will be searched for 1.66 + * @param mode the stdio mode (r, w, a, rb, wb, ab) 1.67 + * @return a magic cookie suitable for passing to stdio.h if the file 1.68 + * was opened; 0 if not opened 1.69 + */ 1.70 +FILE *ljfopen(const char *DISTINCT filename, const char *DISTINCT mode); 1.71 + 1.72 + 1.73 +#ifdef __cplusplus 1.74 +} 1.75 +#endif 1.76 + 1.77 +#endif