summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/common/dir_uncached.c1
-rw-r--r--firmware/common/file.c1
-rw-r--r--firmware/common/filefuncs.c52
-rw-r--r--firmware/export/filefuncs.h31
5 files changed, 86 insertions, 1 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index baba51ca20..061c6323c8 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -39,9 +39,9 @@ common/disk.c
39#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) 39#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
40common/errno.c 40common/errno.c
41#endif /* !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) */ 41#endif /* !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) */
42common/filefuncs.c
42common/memcmp.c 43common/memcmp.c
43common/memchr.c 44common/memchr.c
44common/misc.c
45common/qsort.c 45common/qsort.c
46common/random.c 46common/random.c
47common/sprintf.c 47common/sprintf.c
diff --git a/firmware/common/dir_uncached.c b/firmware/common/dir_uncached.c
index ef9ce6f0af..5ec5c7fb41 100644
--- a/firmware/common/dir_uncached.c
+++ b/firmware/common/dir_uncached.c
@@ -26,6 +26,7 @@
26#include "fat.h" 26#include "fat.h"
27#include "dir.h" 27#include "dir.h"
28#include "debug.h" 28#include "debug.h"
29#include "filefuncs.h"
29 30
30#if ((defined(MEMORYSIZE) && (MEMORYSIZE > 8)) || MEM > 8) 31#if ((defined(MEMORYSIZE) && (MEMORYSIZE > 8)) || MEM > 8)
31#define MAX_OPEN_DIRS 12 32#define MAX_OPEN_DIRS 12
diff --git a/firmware/common/file.c b/firmware/common/file.c
index b7bcbaba46..a7facc3d32 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -26,6 +26,7 @@
26#include "dir_uncached.h" 26#include "dir_uncached.h"
27#include "debug.h" 27#include "debug.h"
28#include "dircache.h" 28#include "dircache.h"
29#include "filefuncs.h"
29#include "system.h" 30#include "system.h"
30 31
31/* 32/*
diff --git a/firmware/common/filefuncs.c b/firmware/common/filefuncs.c
new file mode 100644
index 0000000000..ca9113250a
--- /dev/null
+++ b/firmware/common/filefuncs.c
@@ -0,0 +1,52 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Björn Stenberg
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 ****************************************************************************/
21#include "config.h"
22#include "dir.h"
23#include "stdlib.h"
24#include "string.h"
25
26#ifdef HAVE_MULTIVOLUME
27/* returns on which volume this is, and copies the reduced name
28 (sortof a preprocessor for volume-decorated pathnames) */
29int strip_volume(const char* name, char* namecopy)
30{
31 int volume = 0;
32 const char *temp = name;
33
34 while (*temp == '/') /* skip all leading slashes */
35 ++temp;
36
37 if (*temp && !strncmp(temp, VOL_NAMES, VOL_ENUM_POS))
38 {
39 temp += VOL_ENUM_POS; /* behind special name */
40 volume = atoi(temp); /* number is following */
41 temp = strchr(temp, '/'); /* search for slash behind */
42 if (temp != NULL)
43 name = temp; /* use the part behind the volume */
44 else
45 name = "/"; /* else this must be the root dir */
46 }
47
48 strlcpy(namecopy, name, MAX_PATH);
49
50 return volume;
51}
52#endif /* #ifdef HAVE_MULTIVOLUME */
diff --git a/firmware/export/filefuncs.h b/firmware/export/filefuncs.h
new file mode 100644
index 0000000000..130c5ff4be
--- /dev/null
+++ b/firmware/export/filefuncs.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 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 ****************************************************************************/
21
22#ifndef __INCLUDE_FILEFUNCS_H_
23#define __INCLUDE_FILEFUNCS_H_
24
25#include "config.h"
26
27#ifdef HAVE_MULTIVOLUME
28int strip_volume(const char* name, char* namecopy);
29#endif
30
31#endif /* __INCLUDE_FILEFUNCS_H_ */