projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replaced glib function calls to g_file_get_contents()
[rocksndiamonds.git]
/
src
/
game_bd
/
bd_caveset.c
diff --git
a/src/game_bd/bd_caveset.c
b/src/game_bd/bd_caveset.c
index d04b54c704b8ad5a070da154498a4e534c31aab3..50598fb7a0ec4dbe69a68e0bc69f7bc582a4de78 100644
(file)
--- a/
src/game_bd/bd_caveset.c
+++ b/
src/game_bd/bd_caveset.c
@@
-476,13
+476,13
@@
static void brc_import(guint8 *data)
}
}
}
}
-static void caveset_name_set_from_filename(c
onst c
har *filename)
+static void caveset_name_set_from_filename(char *filename)
{
char *name;
char *c;
/* make up a caveset name from the filename. */
{
char *name;
char *c;
/* make up a caveset name from the filename. */
- name = g
_path_get_basen
ame(filename);
+ name = g
etBaseN
ame(filename);
gd_strcpy(gd_caveset_data->name, name);
free(name);
gd_strcpy(gd_caveset_data->name, name);
free(name);
@@
-504,14
+504,13
@@
static void caveset_name_set_from_filename(const char *filename)
*/
boolean gd_caveset_load_from_file(char *filename)
{
*/
boolean gd_caveset_load_from_file(char *filename)
{
- GError *error = NULL;
gsize length;
char *buf;
gsize length;
char *buf;
- boolean read;
List *new_caveset;
struct stat st;
List *new_caveset;
struct stat st;
+ File *file;
- if (
g_
stat(filename, &st) != 0)
+ if (stat(filename, &st) != 0)
{
Warn("cannot stat() file");
{
Warn("cannot stat() file");
@@
-525,12
+524,22
@@
boolean gd_caveset_load_from_file(char *filename)
return FALSE;
}
return FALSE;
}
- read = g_file_get_contents (filename, &buf, &length, &error);
- if (!read)
+ if (!(file = openFile(filename, MODE_READ)))
{
{
- Warn("
%s", error->messag
e);
+ Warn("
cannot open file '%s'", filenam
e);
- g_error_free(error);
+ return FALSE;
+ }
+
+ buf = checked_malloc(st.st_size + 1);
+ length = readFile(file, buf, 1, st.st_size);
+ buf[length] = '\0';
+
+ closeFile(file);
+
+ if (length < st.st_size)
+ {
+ Warn("cannot read file '%s'", filename);
return FALSE;
}
return FALSE;
}