Move the itoa function to strings.c
This commit is contained in:
parent
5406d648bc
commit
a84f393bd5
11
source/fs.c
11
source/fs.c
@ -181,17 +181,8 @@ u32 firmRead(void *dest, u32 firmType)
|
|||||||
//Complete the string with the .app name
|
//Complete the string with the .app name
|
||||||
concatenateStrings(path, "/00000000.app");
|
concatenateStrings(path, "/00000000.app");
|
||||||
|
|
||||||
//Last digit of the .app
|
|
||||||
u32 i = 42;
|
|
||||||
|
|
||||||
//Convert back the .app name from integer to array
|
//Convert back the .app name from integer to array
|
||||||
u32 tempVersion = firmVersion;
|
hexItoa(firmVersion, &path[35]);
|
||||||
while(tempVersion)
|
|
||||||
{
|
|
||||||
static const char hexDigits[] = "0123456789ABCDEF";
|
|
||||||
path[i--] = hexDigits[tempVersion & 0xF];
|
|
||||||
tempVersion >>= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileRead(dest, path);
|
fileRead(dest, path);
|
||||||
|
|
||||||
|
@ -38,4 +38,18 @@ void concatenateStrings(char *destination, const char *source)
|
|||||||
j = strlen(destination);
|
j = strlen(destination);
|
||||||
|
|
||||||
memcpy(&destination[j], source, i + 1);
|
memcpy(&destination[j], source, i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hexItoa(u32 number, char *out)
|
||||||
|
{
|
||||||
|
const char hexDigits[] = "0123456789ABCDEF";
|
||||||
|
u32 i = 0;
|
||||||
|
|
||||||
|
while(number > 0)
|
||||||
|
{
|
||||||
|
out[7 - i++] = hexDigits[number & 0xF];
|
||||||
|
number >>= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(; i < 8; i++) out[7 - i] = '0';
|
||||||
}
|
}
|
@ -25,4 +25,5 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
int strlen(const char *string);
|
int strlen(const char *string);
|
||||||
void concatenateStrings(char *destination, const char *source);
|
void concatenateStrings(char *destination, const char *source);
|
||||||
|
void hexItoa(u32 number, char *out);
|
Reference in New Issue
Block a user