Welcome! Log In Create A New Profile

Advanced

ISFS_GetFileStats error

Posted by Jigen 
ISFS_GetFileStats error
October 22, 2009 02:40PM
Been working on modding StartPatch to allow selection of what IOS to use, as it now uses cIOS only. Got it all working except I get ISFS_GetFileStats error -101.
ISFS_Initalize and ISFS_Open work just fine. Any ideas? Or is ISFS_GetFileStats just something I can't do from IOS36?

fstats *fs;
fs = NULL;
printf("Done.\nISFS_GetFileStats...\n");
ret = ISFS_GetFileStats(fd, fs);
if (ret < 0) {
printf("ISFS_GetFileStats Error -> ");
printf(err, ret, "\n");
return ret;
}
len = fs->file_length;
buffer = memalign(32, len);
printf("Done.\nISFS_Read...\n");
Re: ISFS_GetFileStats error
October 22, 2009 02:59PM
fs is NULL, that's the problem. You need to allocate memory for it before ISFS_GetFileStats.
Re: ISFS_GetFileStats error
October 22, 2009 03:30PM
Thanks man, worked like a charm.
Re: ISFS_GetFileStats error
October 26, 2009 12:01PM
just as an extra,

you should init pointer by setting them to 0 not null
fstats *fs;
fs = 0;
Re: ISFS_GetFileStats error
October 26, 2009 01:02PM
Quote
SteelSLasher
just as an extra,

you should init pointer by setting them to 0 not null
fstats *fs;
fs = 0;
Explain me why, cause I don't follow you on that one? Null is zero, it just make more sense to use NULL for pointers. Zero should be used for numeric values.

From gctypes.h:
#ifndef NULL
#define NULL			0                        ///< Pointer to 0
#endif



Edited 1 time(s). Last edit at 10/26/2009 01:03PM by Crayon.
Re: ISFS_GetFileStats error
October 27, 2009 04:26AM
Null isn't necessarily zero in all cases. I've always thought it better to initialize pointers to null instead of zero as a safety measure. In the event the pointer isn't set later before being accessed, the program would fail instead of "succeeding" and writing/reading from the wrong place.
Re: ISFS_GetFileStats error
October 29, 2009 09:33AM
Null is zero in c++ per the ISO standard.
Re: ISFS_GetFileStats error
October 29, 2009 03:48PM
Just to confirm what henke37and Jigen said. This from stdio.h in Visual C++:
/* Define NULL pointer value */

#ifndef NULL
#ifdef  __cplusplus
#define NULL    0
#else
#define NULL    ((void *)0)
#endif
#endif
NULL is not always zero, but in C++ it is :)

Anyway, everyone agrees that it is best to use NULL for pointers (except SteelSLasher).
Re: ISFS_GetFileStats error
October 31, 2009 01:16PM
Quote
Crayon
Anyway, everyone agrees that it is best to use NULL for pointers (except SteelSLasher).
its not whether i agree or not, i just learnt that they should be initiated as 0 not null
Sorry, only registered users may post in this forum.

Click here to login