2002-04-27 17:10:15 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Felix Arends
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2002-04-28 16:52:43 +00:00
|
|
|
#include <io.h>
|
2002-04-30 21:15:02 +00:00
|
|
|
#include <windows.h>
|
2002-04-28 16:52:43 +00:00
|
|
|
#include <malloc.h>
|
2002-04-28 19:27:16 +00:00
|
|
|
#include "dir-win32.h"
|
2002-04-27 17:10:15 +00:00
|
|
|
|
|
|
|
// Directory operations
|
|
|
|
//
|
|
|
|
|
|
|
|
// opendir
|
|
|
|
// open directory for scanning
|
|
|
|
DIR *opendir (
|
2004-04-20 11:29:46 +00:00
|
|
|
const char *dirname // directory name
|
2002-04-27 17:10:15 +00:00
|
|
|
)
|
|
|
|
{
|
2002-04-28 16:52:43 +00:00
|
|
|
DIR *p = (DIR*)malloc(sizeof(DIR));
|
|
|
|
struct _finddata_t fd;
|
2002-04-30 21:15:02 +00:00
|
|
|
unsigned int i;
|
|
|
|
char *s = (char*)malloc(strlen(dirname) + 5);
|
|
|
|
wsprintf (s, "%s", dirname);
|
|
|
|
|
|
|
|
for (i = 0; i < strlen(s); i++)
|
|
|
|
if (s[i] == '/')
|
|
|
|
s[i] = '\\';
|
|
|
|
|
|
|
|
if (s[i - 1] != '\\')
|
|
|
|
{
|
|
|
|
s[i] = '\\';
|
|
|
|
s[++i] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputDebugString (s);
|
|
|
|
|
|
|
|
wsprintf (s, "%s*.*", s);
|
|
|
|
|
|
|
|
if ((p->handle = _findfirst (s, &fd)) == -1)
|
2002-04-28 09:30:54 +00:00
|
|
|
{
|
2002-04-30 21:15:02 +00:00
|
|
|
free (s);
|
2002-04-28 09:30:54 +00:00
|
|
|
free (p);
|
2002-04-28 19:27:16 +00:00
|
|
|
return 0;
|
2002-04-28 09:30:54 +00:00
|
|
|
}
|
2002-04-30 21:15:02 +00:00
|
|
|
free (s);
|
2002-04-27 17:10:15 +00:00
|
|
|
return p;
|
2002-04-28 16:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// closedir
|
|
|
|
// close directory
|
|
|
|
int closedir (
|
|
|
|
DIR *dir // previously opened dir search
|
|
|
|
)
|
|
|
|
{
|
|
|
|
free(dir);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// read dir
|
|
|
|
// read next entry in directory
|
2002-04-28 19:27:16 +00:00
|
|
|
struct dirent *readdir (
|
|
|
|
DIR *dir
|
|
|
|
)
|
2002-04-28 16:52:43 +00:00
|
|
|
{
|
|
|
|
struct _finddata_t fd;
|
|
|
|
if (_findnext (dir->handle, &fd) == -1)
|
2002-04-28 19:27:16 +00:00
|
|
|
return 0;
|
2002-04-28 16:52:43 +00:00
|
|
|
memcpy (dir->fd.d_name, fd.name, 256);
|
2002-05-08 07:06:16 +00:00
|
|
|
|
2003-06-18 04:48:40 +00:00
|
|
|
dir->fd.attribute = fd.attrib & 0x3f;
|
2002-05-08 07:06:16 +00:00
|
|
|
dir->fd.size = fd.size;
|
|
|
|
dir->fd.startcluster = 0 ;
|
|
|
|
|
|
|
|
|
2002-04-28 16:52:43 +00:00
|
|
|
return &dir->fd;
|
2002-11-12 19:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void fat_size(unsigned int* size, unsigned int* free)
|
|
|
|
{
|
|
|
|
*size = 2049;
|
|
|
|
*free = 1037;
|
|
|
|
}
|