Fix file system browser issue on 64bits system.

git-svn-id: svn://svn.code.sf.net/p/hxcfloppyemu/code/HxCFloppyEmulator/libhxcadaptor/trunk@1399 63fa2f70-6a9b-4bc4-b855-9c6a949b1d69
This commit is contained in:
Jean-François DEL NERO
2016-12-30 13:50:51 +00:00
parent 0565cac634
commit 78adf8f6ca
3 changed files with 71 additions and 23 deletions
+51 -17
View File
@@ -107,6 +107,10 @@ int hxc_open (const char *filename, int flags, ...)
unsigned int mode = 0;
va_list ap;
#if defined (DEBUG)
printf("hxc_open : filename=%s flags=%x\n",filename,flags);
#endif
va_start (ap, flags);
if (flags & O_CREAT)
mode = va_arg (ap, unsigned int);
@@ -149,6 +153,10 @@ FILE *hxc_fopen (const char *filename, const char *mode)
const char *ptr;
FILE *stream;
#if defined (DEBUG)
printf("hxc_fopen : filename=%s mode=%s\n",filename,mode);
#endif
// Try the classic way (ascii path)
stream = fopen(filename,mode);
@@ -245,6 +253,11 @@ FILE *hxc_fopen (const char *filename, const char *mode)
int hxc_fread(void * ptr, size_t size, FILE *f)
{
#if defined (DEBUG)
printf("hxc_fread : ptr=%p size=%zu file:%p\n",ptr,size,f);
#endif
if( fread(ptr,size,1,f) != 1 )
{
return 1; // Error
@@ -262,12 +275,18 @@ char * hxc_fgets(char * str, int num, FILE *f)
int hxc_fclose(FILE * f)
{
#if defined (DEBUG)
printf("hxc_fclose : file:%p\n",f);
#endif
return fclose(f);
}
int hxc_statex( const char *filename, struct stat *buf)
{
#if defined (DEBUG)
printf("hxc_statex : filename=%s\n",filename);
#endif
#if defined (WIN32)
wchar_t wpath[MAX_PATH+1];
@@ -300,8 +319,12 @@ int hxc_stat( const char *filename, struct stat *buf)
return hxc_statex(filename,buf);
}
int hxc_find_first_file(char *folder, char *file, filefoundinfo* fileinfo)
void * hxc_find_first_file(char *folder, char *file, filefoundinfo* fileinfo)
{
#if defined (DEBUG)
printf("hxc_find_first_file : folder=%s file=%s\n",folder,file);
#endif
#if defined (WIN32)
HANDLE hfindfile;
@@ -336,12 +359,12 @@ int hxc_find_first_file(char *folder, char *file, filefoundinfo* fileinfo)
fileinfo->size = FindFileData.nFileSizeLow;
free(folderstr);
return (int)hfindfile;
return (void*)hfindfile;
}
else
{
free(folderstr);
return -1;
return 0;
}
#else
@@ -377,35 +400,40 @@ int hxc_find_first_file(char *folder, char *file, filefoundinfo* fileinfo)
strncpy(fileinfo->filename,d->d_name,256);
free(tmpstr);
return (int)dir;
return (void*)dir;
}
free(tmpstr);
}
closedir (dir);
dir=(DIR *)-1;
dir=0;
}
closedir (dir);
dir=(DIR *)-1;
dir=0;;
}
else
{
dir=(DIR *)-1;
dir=0;
}
return (int)dir;
return (void*)dir;
#endif
return -1;
return 0;
}
int hxc_find_next_file(int handleff, char *folder, char *file, filefoundinfo* fileinfo)
int hxc_find_next_file(void* handleff, char *folder, char *file, filefoundinfo* fileinfo)
{
int ret;
#if defined (DEBUG)
printf("hxc_find_next_file : handleff:%p folder=%s file=%s\n",handleff,folder,file);
#endif
#if defined (WIN32)
WIN32_FIND_DATAW FindFileData;
@@ -468,15 +496,18 @@ int hxc_find_next_file(int handleff, char *folder, char *file, filefoundinfo* fi
return ret;
}
int hxc_find_close(int handle)
int hxc_find_close(void* handle)
{
#if defined (DEBUG)
printf("hxc_find_close : handle:%p\n",handle);
#endif
#if defined (WIN32)
FindClose((void*)handle);
if(handle)
FindClose((void*)handle);
#else
DIR * dir;
dir = (DIR*) handle;
if(dir)
closedir(dir);
if(handle)
closedir((DIR*) handle);
#endif
return 0;
}
@@ -513,6 +544,9 @@ char * hxc_getcurrentdirectory(char *currentdirectory,int buffersize)
int hxc_mkdir(char * folder)
{
#if defined (DEBUG)
printf("hxc_mkdir : folder:%s\n",folder);
#endif
#ifdef WIN32
_mkdir(folder);
+17 -3
View File
@@ -66,6 +66,7 @@
#include <stdint.h>
#include "internal_libhxcfe.h"
#include "libhxcfe.h"
#include "usb_hxcfloppyemulator.h"
#include "libhxcadaptor.h"
@@ -182,7 +183,6 @@ int hxc_waitevent(HXCFE* floppycontext,int id,int timeout)
struct timeval now;
struct timespec timeoutstr;
int retcode;
int ret;
pthread_mutex_lock(&eventtab[id]->eMutex);
gettimeofday(&now,0);
@@ -284,6 +284,8 @@ int hxc_createthread(HXCFE* floppycontext,void* hwcontext,THREADFUNCTION thread,
{
#ifdef WIN32
DWORD sit;
HANDLE thread_handle;
threadinit *threadinitptr;
threadinitptr=(threadinit*)malloc(sizeof(threadinit));
@@ -291,17 +293,25 @@ int hxc_createthread(HXCFE* floppycontext,void* hwcontext,THREADFUNCTION thread,
threadinitptr->hxcfloppyemulatorcontext=floppycontext;
threadinitptr->hwcontext=hwcontext;
CreateThread(NULL,8*1024,&ThreadProc,threadinitptr,0,&sit);
thread_handle = CreateThread(NULL,8*1024,&ThreadProc,threadinitptr,0,&sit);
if(!thread_handle)
{
floppycontext->hxc_printf(MSG_ERROR,"hxc_createthread : CreateThread failed -> 0x.8X", GetLastError());
}
return sit;
#else
unsigned long sit;
int ret;
pthread_t threadid;
pthread_attr_t threadattrib;
threadinit *threadinitptr;
struct sched_param param;
sit = 0;
pthread_attr_init(&threadattrib);
pthread_attr_setinheritsched(&threadattrib, PTHREAD_EXPLICIT_SCHED);
@@ -324,7 +334,11 @@ int hxc_createthread(HXCFE* floppycontext,void* hwcontext,THREADFUNCTION thread,
threadinitptr->hxcfloppyemulatorcontext=floppycontext;
threadinitptr->hwcontext=hwcontext;
pthread_create(&threadid, &threadattrib,ThreadProc, threadinitptr);
ret = pthread_create(&threadid, &threadattrib,ThreadProc, threadinitptr);
if(ret)
{
floppycontext->hxc_printf(MSG_ERROR,"hxc_createthread : pthread_create failed -> %d",ret);
}
return sit;
#endif
+3 -3
View File
@@ -53,9 +53,9 @@ int hxc_fclose(FILE * f);
#endif
int hxc_stat( const char *filename, struct stat *buf);
int hxc_find_first_file(char *folder,char *file,filefoundinfo* fileinfo);
int hxc_find_next_file(int handleff,char *folder,char *file,filefoundinfo* fileinfo);
int hxc_find_close(int 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);