mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 12:23:31 +00:00
[FATTEN]
* Fix the integer types for non-windows platforms (assume they have stdint.h instead of assuming embedded). * Fix file I/O, which was just barely working enough to pass the one test I did. svn path=/trunk/; revision=69105
This commit is contained in:
@@ -31,6 +31,10 @@ DSTATUS disk_initialize(
|
||||
return 0;
|
||||
|
||||
driveHandle[0] = fopen(imageFileName, "r+b");
|
||||
if(!driveHandle[0])
|
||||
{
|
||||
driveHandle[0] = fopen(imageFileName, "w+");
|
||||
}
|
||||
|
||||
if (driveHandle[0] != NULL)
|
||||
return 0;
|
||||
@@ -80,10 +84,10 @@ DRESULT disk_read(
|
||||
|
||||
result = fread(buff, 512, count, driveHandle[pdrv]);
|
||||
|
||||
if (result == count)
|
||||
return RES_OK;
|
||||
if (result != count)
|
||||
return RES_ERROR;
|
||||
|
||||
return RES_ERROR;
|
||||
return RES_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +118,8 @@ DRESULT disk_write(
|
||||
return RES_ERROR;
|
||||
|
||||
result = fwrite(buff, 512, count, driveHandle[pdrv]);
|
||||
return RES_ERROR;
|
||||
|
||||
if (result != (512 * count))
|
||||
if (result != count)
|
||||
return RES_ERROR;
|
||||
|
||||
return RES_OK;
|
||||
@@ -155,9 +158,15 @@ DRESULT disk_ioctl(
|
||||
*(DWORD*)buff = 512;
|
||||
return RES_OK;
|
||||
case GET_SECTOR_COUNT:
|
||||
fseek(driveHandle[pdrv], 0, SEEK_END);
|
||||
*(DWORD*)buff = ftell(driveHandle[pdrv]) / 512;
|
||||
{
|
||||
int temp = 0;
|
||||
if(fseek(driveHandle[pdrv], 0, SEEK_END))
|
||||
printf("fseek failed!\n");
|
||||
else
|
||||
temp = ftell(driveHandle[pdrv]);
|
||||
*(DWORD*)buff = temp/512;
|
||||
return RES_OK;
|
||||
}
|
||||
case SET_SECTOR_COUNT:
|
||||
{
|
||||
int count = *(DWORD*)buff;
|
||||
|
||||
@@ -5,28 +5,30 @@
|
||||
#ifndef _FF_INTEGER
|
||||
#define _FF_INTEGER
|
||||
|
||||
#ifdef _WIN32 /* FatFs development platform */
|
||||
#ifdef _WIN32 /* Windows */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#else /* Embedded platform */
|
||||
#else /* Unixes */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* This type MUST be 8 bit */
|
||||
typedef unsigned char BYTE;
|
||||
typedef uint8_t BYTE;
|
||||
|
||||
/* These types MUST be 16 bit */
|
||||
typedef short SHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
typedef int16_t SHORT;
|
||||
typedef uint16_t WORD;
|
||||
typedef uint16_t WCHAR;
|
||||
|
||||
/* These types MUST be 16 bit or 32 bit */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef int_fast16_t INT;
|
||||
typedef uint_fast16_t UINT;
|
||||
|
||||
/* These types MUST be 32 bit */
|
||||
typedef long LONG;
|
||||
typedef unsigned long DWORD;
|
||||
typedef int32_t LONG;
|
||||
typedef uint32_t DWORD;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user