summaryrefslogtreecommitdiff
path: root/utils/jz4740_tools/HXFmerge.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/jz4740_tools/HXFmerge.c')
-rw-r--r--[-rwxr-xr-x]utils/jz4740_tools/HXFmerge.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/utils/jz4740_tools/HXFmerge.c b/utils/jz4740_tools/HXFmerge.c
index f90d094fd9..fb5a0bf2f3 100755..100644
--- a/utils/jz4740_tools/HXFmerge.c
+++ b/utils/jz4740_tools/HXFmerge.c
@@ -1,6 +1,23 @@
1/* 1/***************************************************************************
2Made by Maurus Cuelenaere 2 * __________ __ ___.
3*/ 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
4 21
5#include <stdio.h> 22#include <stdio.h>
6#include <stdlib.h> 23#include <stdlib.h>
@@ -42,8 +59,8 @@ static unsigned int le2int(unsigned char* buf)
42#define MIN(a, b) (a > b ? b : a) 59#define MIN(a, b) (a > b ? b : a)
43static char* replace(char* str) 60static char* replace(char* str)
44{ 61{
45 char tmp[255]; 62 static char tmp[255];
46 memcpy(tmp, str, MIN(strlen(str), 255); 63 memcpy(tmp, str, MIN(strlen(str), 255));
47 char *ptr = tmp; 64 char *ptr = tmp;
48 while(*ptr != 0) 65 while(*ptr != 0)
49 { 66 {
@@ -156,19 +173,32 @@ static void merge_hxf(const char* indir, FILE* outfile, const char* add)
156 173
157 if(strlen(add)>0) 174 if(strlen(add)>0)
158 { 175 {
176#ifdef _DIRENT_HAVE_D_NAMLEN
159 WRITE(int2le(dirs->d_namlen+strlen(add)), 4); 177 WRITE(int2le(dirs->d_namlen+strlen(add)), 4);
178#else
179 WRITE(int2le(strlen(dirs->d_name)+strlen(add)), 4);
180#endif
160#ifndef _WIN32 181#ifndef _WIN32
161 WRITE(replace(add), strlen(add)-1); 182 WRITE(replace(&add), strlen(add)-1);
162#else 183#else
163 WRITE(add, strlen(add)-1); 184 WRITE(add, strlen(add)-1);
164#endif 185#endif
165 WRITE(PATH_SEPARATOR, 1); 186 WRITE(PATH_SEPARATOR, 1);
187#ifdef _DIRENT_HAVE_D_NAMLEN
166 WRITE(dirs->d_name, dirs->d_namlen); 188 WRITE(dirs->d_name, dirs->d_namlen);
189#else
190 WRITE(dirs->d_name, strlen(dirs->d_name));
191#endif
167 } 192 }
168 else 193 else
169 { 194 {
195#ifdef _DIRENT_HAVE_D_NAMLEN
170 WRITE(int2le(dirs->d_namlen), 4); 196 WRITE(int2le(dirs->d_namlen), 4);
171 WRITE(dirs->d_name, dirs->d_namlen); 197 WRITE(dirs->d_name, dirs->d_namlen);
198#else
199 WRITE(int2le(strlen(dirs->d_name)), 4);
200 WRITE(dirs->d_name, strlen(dirs->d_name));
201#endif
172 } 202 }
173 WRITE(int2le(filesize), 4); 203 WRITE(int2le(filesize), 4);
174 if(filesize>0) 204 if(filesize>0)