get file size function.

git-svn-id: svn://svn.code.sf.net/p/hxcfloppyemu/code/HxCFloppyEmulator/libhxcadaptor/trunk@1460 63fa2f70-6a9b-4bc4-b855-9c6a949b1d69
This commit is contained in:
Jean-François DEL NERO
2018-01-19 22:17:03 +00:00
parent ec4f93c4ed
commit ecf210d7ca
2 changed files with 56 additions and 30 deletions
+27 -1
View File
@@ -501,7 +501,7 @@ int hxc_find_close(void* handle)
#if defined (DEBUG)
printf("hxc_find_close : handle:%p\n",handle);
#endif
#if defined (WIN32)
if(handle)
FindClose((void*)handle);
@@ -555,3 +555,29 @@ int hxc_mkdir(char * folder)
#endif
return 0;
}
int hxc_fgetsize( FILE * f )
{
int cur_pos,filesize;
if( f )
{
cur_pos = ftell(f);
if( cur_pos >= 0 )
{
if(fseek (f , 0 , SEEK_END))
return 0;
filesize = ftell(f);
if( filesize < 0 )
filesize = 0;
fseek (f , cur_pos , SEEK_SET);
}
return filesize;
}
return 0;
}
+29 -29
View File
@@ -20,53 +20,53 @@ typedef struct filefoundinfo_
int size;
}filefoundinfo;
int hxc_setevent(HXCFE* floppycontext,unsigned char id);
unsigned long hxc_createevent(HXCFE* floppycontext,unsigned char id);
int hxc_waitevent(HXCFE* floppycontext,int id,int timeout);
void hxc_pause(int ms);
int hxc_createthread(HXCFE* floppycontext,void* hwcontext,THREADFUNCTION thread,int priority);
int hxc_setevent( HXCFE* floppycontext, unsigned char id );
unsigned long hxc_createevent( HXCFE* floppycontext, unsigned char id );
int hxc_waitevent( HXCFE* floppycontext, int id, int timeout );
void hxc_pause( int ms );
int hxc_createthread( HXCFE* floppycontext, void* hwcontext, THREADFUNCTION thread, int priority );
unsigned long hxc_createcriticalsection(HXCFE* floppycontext,unsigned char id);
void hxc_entercriticalsection(HXCFE* floppycontext,unsigned char id);
void hxc_leavecriticalsection(HXCFE* floppycontext,unsigned char id);
void hxc_destroycriticalsection(HXCFE* floppycontext,unsigned char id);
unsigned long hxc_createcriticalsection( HXCFE* floppycontext, unsigned char id );
void hxc_entercriticalsection( HXCFE* floppycontext, unsigned char id );
void hxc_leavecriticalsection( HXCFE* floppycontext, unsigned char id );
void hxc_destroycriticalsection( HXCFE* floppycontext, unsigned char id );
/////////////// String functions ///////////////
#ifndef WIN32
//void strlwr(char *string)
#endif
char * hxc_strupper(char * str);
char * hxc_strlower(char * str);
char * hxc_strupper( char * str );
char * hxc_strlower( char * str );
/////////////// File functions ////////////////
int hxc_open (const char *filename, int flags, ...);
FILE *hxc_fopen (const char *filename, const char *mode);
int hxc_fread(void * ptr, size_t size, FILE *f);
char * hxc_fgets(char * str, int num, FILE *f);
int hxc_fclose(FILE * f);
int hxc_open ( const char *filename, int flags, ... );
FILE *hxc_fopen ( const char *filename, const char *mode );
int hxc_fread( void * ptr, size_t size, FILE *f );
char * hxc_fgets( char * str, int num, FILE *f );
int hxc_fclose( FILE * f );
int hxc_fgetsize( FILE * f );
#ifndef stat
#include <sys/stat.h>
#endif
int hxc_stat( const char *filename, struct stat *buf);
int hxc_stat( const char *filename, struct stat *buf );
void* hxc_find_first_file(char *folder,char *file,filefoundinfo* fileinfo);
int hxc_find_next_file(void* handleff,char *folder,char *file,filefoundinfo* fileinfo);
int hxc_find_close(void* handle);
void* hxc_find_first_file( char *folder, char *file, filefoundinfo* fileinfo );
int hxc_find_next_file( void* handleff, char *folder, char *file, filefoundinfo* fileinfo );
int hxc_find_close( void* handle );
int hxc_mkdir(char * folder);
int hxc_mkdir( char * folder );
char * hxc_getcurrentdirectory(char *currentdirectory,int buffersize);
char * hxc_getcurrentdirectory( char *currentdirectory, int buffersize );
char * hxc_getfilenamebase(char * fullpath,char * filenamebase);
char * hxc_getfilenameext(char * fullpath,char * filenameext);
int hxc_getfilenamewext(char * fullpath,char * filenamewext);
int hxc_getpathfolder(char * fullpath,char * folder);
int hxc_checkfileext(char * path,char *ext);
int hxc_getfilesize(char * path);
char * hxc_getfilenamebase( char * fullpath, char * filenamebase );
char * hxc_getfilenameext( char * fullpath, char * filenameext );
int hxc_getfilenamewext( char * fullpath, char * filenamewext );
int hxc_getpathfolder( char * fullpath, char * folder );
int hxc_checkfileext( char * path, char *ext );
int hxc_getfilesize( char * path );
#ifdef __cplusplus
}