Make file::read and file::write use the new QFS functions. This allows

reading files out of paks from GIB. file::find still needs to be updated
(and renamed).
This commit is contained in:
Brian Koropoff 2003-05-22 02:32:38 +00:00
parent 6a8469df14
commit c3d18bd53a

View file

@ -787,15 +787,11 @@ GIB_File_Read_f (void)
GIB_Error ("file", "%s: null filename provided", GIB_Argv (0));
return;
}
if (GIB_File_Transform_Path (GIB_Argd (1))) {
GIB_Error ("access",
"%s: access to %s denied", GIB_Argv (0), GIB_Argv (1));
return;
}
if (!(ret = GIB_Return (0)))
return;
path = GIB_Argv (1);
file = Qopen (path, "r");
QFS_FOpenFile (path, &file);
if (file) {
len = Qfilesize (file);
ret->size = len + 1;
@ -803,8 +799,7 @@ GIB_File_Read_f (void)
Qread (file, ret->str, len);
ret->str[len] = 0;
Qclose (file);
}
if (!file) {
} else {
GIB_Error ("file",
"%s: could not read %s: %s", GIB_Argv (0), path,
strerror (errno));
@ -815,7 +810,6 @@ GIB_File_Read_f (void)
static void
GIB_File_Write_f (void)
{
QFile *file;
char *path;
if (GIB_Argc () != 3) {
@ -826,20 +820,9 @@ GIB_File_Write_f (void)
GIB_Error ("file", "%s: null filename provided", GIB_Argv (0));
return;
}
if (GIB_File_Transform_Path (GIB_Argd (1))) {
GIB_Error ("access",
"%s: access to %s denied", GIB_Argv (0), GIB_Argv (1));
return;
}
path = GIB_Argv (1);
if (!(file = Qopen (path, "w"))) {
GIB_Error ("file",
"%s: could not open %s for writing: %s", GIB_Argv (0), path,
strerror (errno));
return;
}
Qprintf (file, "%s", GIB_Argv (2));
Qclose (file);
QFS_WriteFile (path, GIB_Argv(2), GIB_Argd(2)->size-1);
}
static void