Author: dquintana
Date: Tue Sep 8 00:28:28 2015
New Revision: 69105
URL:
http://svn.reactos.org/svn/reactos?rev=69105&view=rev
Log:
[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.
Modified:
trunk/reactos/tools/fatten/fatfs/diskio.c
trunk/reactos/tools/fatten/fatfs/integer.h
Modified: trunk/reactos/tools/fatten/fatfs/diskio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/diskio.…
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/diskio.c [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatfs/diskio.c [iso-8859-1] Tue Sep 8 00:28:28 2015
@@ -31,6 +31,10 @@
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 @@
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 @@
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 @@
*(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;
Modified: trunk/reactos/tools/fatten/fatfs/integer.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/integer…
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/integer.h [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatfs/integer.h [iso-8859-1] Tue Sep 8 00:28:28 2015
@@ -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