Use const strings for file names

This commit is contained in:
kichikuou
2020-07-12 13:41:57 +09:00
parent 4c58510a37
commit 1a3b779ace
16 changed files with 46 additions and 46 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
#include "modules.h"
#include "nact.h"
extern void ndd_init(char *files[], int n);
extern void ndd_init(const char *files[], int n);
extern void ndd_run(int demonum);
static void Init() {
+2 -2
View File
@@ -39,7 +39,7 @@
// 2: Meteo
struct nddemo {
char **fn;
const char **fn;
alk_t *alk;
surface_t *sf[10];
};
@@ -52,7 +52,7 @@ static int ndemo_nums[3] = {150, 603, 467};
extern surface_t *jpeg2surface(FILE *fp, int offset);
// ALKファイルの登録
void ndd_init(char *files[], int n) {
void ndd_init(const char *files[], int n) {
int i;
ndd.fn = malloc(sizeof(char *) * n);
+1 -1
View File
@@ -24,6 +24,6 @@
#ifndef __SACTAMASK_H__
#define __SACTAMASK_H__
extern int smask_init(char *path);
extern int smask_init(const char *path);
#endif
+1 -1
View File
@@ -41,7 +41,7 @@
#include "LittleEndian.h"
#include "alk.h"
alk_t *alk_new(char *path) {
alk_t *alk_new(const char *path) {
alk_t *alk;
int i, fd;
char *adr;
+1 -1
View File
@@ -44,7 +44,7 @@ typedef struct {
int *offset; /* 各ファイルへのオフセット */
} alk_t;
extern alk_t *alk_new(char *path);
extern alk_t *alk_new(const char *path);
extern int alk_free(alk_t *alk);
extern char *alk_get(alk_t *alk, int no);
+1 -1
View File
@@ -103,7 +103,7 @@ void ald_freedata(dridata *data) {
* cnt : number in file name array
* mmap: mmap file or not
*/
void ald_init(int type, char **file, int cnt, boolean mmap) {
void ald_init(int type, const char **file, int cnt, boolean mmap) {
/* check wrong type */
if (type < DRIFILETYPEMAX) {
dri[type] = dri_init(file, cnt, mmap);
+1 -1
View File
@@ -38,7 +38,7 @@ typedef enum {
DRIFILE_BGM =6 /* stream music data */
} DRIFILETYPE;
extern void ald_init(int type, char **file, int cnt, boolean mmap);
extern void ald_init(int type, const char **file, int cnt, boolean mmap);
extern dridata *ald_getdata(DRIFILETYPE type, int no);
extern void ald_freedata(dridata *data);
+2 -2
View File
@@ -175,13 +175,13 @@ static void get_fileptr(drifiles *d, FILE *fp, int disk) {
* mmapping: mmap file or not
* return: drifile object
*/
drifiles *dri_init(char **file, int cnt, boolean mmapping) {
drifiles *dri_init(const char **file, int cnt, boolean mmapping) {
drifiles *d = calloc(1, sizeof(drifiles));
FILE *fp;
int i;
boolean gotmap = FALSE;
long filesize;
char **filetop = file;
const char **filetop = file;
for (i = 0; i < cnt; i++) {
if (*(file + i) == NULL) continue;
+1 -1
View File
@@ -55,7 +55,7 @@ struct _dridata {
};
typedef struct _dridata dridata;
extern drifiles *dri_init(char **file, int cnt, boolean mmapping);
extern drifiles *dri_init(const char **file, int cnt, boolean mmapping);
extern dridata *dri_getdata(drifiles *d, int no);
#endif /* !__DRI__ */
+4 -4
View File
@@ -38,7 +38,7 @@ struct fnametable {
static char *saveDataPath;
static boolean newfile_kanjicode_utf8 = TRUE;
static char *get_fullpath(const char* dir, char *filename) {
static char *get_fullpath(const char* dir, const char *filename) {
char *fn = malloc(strlen(filename) + strlen(dir) + 3);
if (fn == NULL) {
return NULL;
@@ -51,7 +51,7 @@ static char *get_fullpath(const char* dir, char *filename) {
/* list up file in current directory */
/* name : save/load directory */
void fc_init(char *name) {
void fc_init(const char *name) {
saveDataPath = strdup(name);
}
@@ -75,7 +75,7 @@ static char *fc_search(const char *fname_sjis, const char *dir) {
return found;
}
FILE *fc_open(char *filename, char type) {
FILE *fc_open(const char *filename, char type) {
char *fullpath = fc_search(filename, saveDataPath);
if (fullpath == NULL) {
if (type == 'r') {
@@ -106,7 +106,7 @@ FILE *fc_open(char *filename, char type) {
return fp;
}
void fc_backup_oldfile(char *filename) {
void fc_backup_oldfile(const char *filename) {
#ifndef __EMSCRIPTEN__
char *newname;
+3 -3
View File
@@ -27,9 +27,9 @@
#define FILENAME_KANJI_CODE_UTF8 0
#define FILENAME_KANJI_CODE_SJIS 1
extern void fc_init(char *name);
extern FILE *fc_open(char *filename, char type);
extern void fc_backup_oldfile(char *filename);
extern void fc_init(const char *name);
extern FILE *fc_open(const char *filename, char type);
extern void fc_backup_oldfile(const char *filename);
extern void fc_set_default_kanjicode(int c);
#endif /* !__FILECHECK_H__ */
+9 -9
View File
@@ -29,16 +29,16 @@
#include "savedata.h"
typedef struct {
char *game_fname[DRIFILETYPEMAX][DRIFILEMAX];
const char *game_fname[DRIFILETYPEMAX][DRIFILEMAX];
int cnt[DRIFILETYPEMAX];
char *save_path;
char *save_fname[SAVE_MAXNUMBER];
char *ain;
char *wai;
char *bgi;
char *sact01;
char *init;
char *alk[10];
const char *save_path;
const char *save_fname[SAVE_MAXNUMBER];
const char *ain;
const char *wai;
const char *bgi;
const char *sact01;
const char *init;
const char *alk[10];
} GameResource;
boolean initGameResource(GameResource *gr, const char *gr_fname);
+14 -14
View File
@@ -125,20 +125,20 @@ typedef struct {
/* データのファイル名 */
struct {
char *scenario[2];
char *graphics[2];
char *wav[2];
char *midi[2];
char *data[2];
char *resource[2];
char *bgm[2];
char *save[27];
char *savedir;
char *init;
char *bgi;
char *wai;
char *sact01;
char *alk[10];
const char *scenario[2];
const char *graphics[2];
const char *wav[2];
const char *midi[2];
const char *data[2];
const char *resource[2];
const char *bgm[2];
const char *save[27];
const char *savedir;
const char *init;
const char *bgi;
const char *wai;
const char *sact01;
const char *alk[10];
} files;
int frame_count;
+1 -1
View File
@@ -50,7 +50,7 @@ typedef struct {
/* System39.ain 全体の情報 */
typedef struct {
char *path_to_ain; /* system39.ain へのパス */
const char *path_to_ain; /* system39.ain へのパス */
int dllnum; /* DLL の数 */
int fncnum; /* FUNC の数 */
+2 -2
View File
@@ -64,13 +64,13 @@ EM_JS(void, scheduleSync, (), {
#endif
/* savefile がある directory を登録 */
void save_set_path(char *path) {
void save_set_path(const char *path) {
nact->files.savedir = strdup(path);
fc_init(path);
}
/* savefile を登録 */
void save_register_file(char *name, int index) {
void save_register_file(const char *name, int index) {
saveDataFile[index] = strdup(name);
}
+2 -2
View File
@@ -125,8 +125,8 @@ extern int save_load_var_with_file(char *filename, int *start, int cnt);
extern int save_save_str_with_file(char *filename, int start, int cnt);
extern int save_load_str_with_file(char *filename, int start, int cnt);
extern BYTE* load_cg_with_file(char *file, int *status, long *filesize);
extern void save_set_path(char *path);
extern void save_register_file(char *name, int index);
extern void save_set_path(const char *path);
extern void save_register_file(const char *name, int index);
extern char* save_get_file(int index);
extern int save_delete_file(int index);