#include <dos.h> // for getdate()
#include <shfolder.h>
#include <io.h> /* _chmod() */
#include <sys/stat.h> /* _S_IWRITE */
#define FOPEN _tfopen // TFileStreamとかを使うべきなんだけど
#define FOPEN_READ _T("rb")
#define FOPEN_APPEND _T("a+b")
#define yGetFileNameToOpen(fn) fn
void yocread(char *fn, ULONG sp, char *str, int len)
{
FILE *fh;
fh = FOPEN(yGetFileNameToOpen(fn),FOPEN_READ);
if( fh != NULL ) {
if( sp > 0 )
fseek(fh,sp,SEEK_SET);
fread(str,sizeof(char),len,fh);
fclose(fh);
}
}
ULONG yfsize( LPSTR filename )
{
ULONG ret = 0;
FILE *fh;
fh = FOPEN(yGetFileNameToOpen(filename),FOPEN_READ);
if( fh != NULL ) {
ret = fseek(fh,0,SEEK_END);
fclose(fh);
}
return ret;
}
void yocwrite(char *fn, ULONG sp, char *str, int len)
{
FILE *fh;
int ret;
if( len <= 0 )
len = strlen(str);
fh = FOPEN(yGetFileNameToOpen(fn),FOPEN_APPEND); /* append binary */
if( fh != NULL ) {
fseek(fh,sp,SEEK_SET);
fwrite(str,sizeof(char),len,fh);
fclose(fh);
}
}
LPSTR YAllocMem( ULONG size )
{
return (LPSTR)malloc(size);
}
void YFreeMem( LPSTR ptr )
{
if( ptr ) {
free(ptr);
}
}
Copyright(C) 2008 Y.Yonemura All rights reserved.