/*---------------------------------------------------------------------------* Project: Sample demo program for NAND library File: directory.c Programmer: HIRATSU Daisuke Copyright (C) 2006 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: directory.c,v $ Revision 1.10 2006/09/28 07:01:48 hiratsu Memory allocation for NANDReadDir() was wrong. Fixed. Revision 1.9 2006/07/19 13:02:56 hiratsu Now, this demo can distinguish between file and directory. Revision 1.8 2006/06/08 11:12:05 hiratsu Buffer allocation for NANDReadDir was wrong. Fixed. Now printDir() prints extra information, such as permission. Revision 1.7 2006/06/05 13:10:30 hiratsu Removed NANDFinalize(). Now this program outpus current (home) directory. Revision 1.6 2006/05/03 09:06:21 hiratsu Revised flow. Revision 1.5 2006/04/27 17:57:35 orest Added NANDFinalize() api. Revision 1.4 2006/03/17 04:39:05 hiratsu Adapted the source to real file system module. Revision 1.3 2006/03/06 12:05:34 hiratsu Removed finalize function. Revision 1.2 2006/03/06 09:59:08 kawaset Eliminated warnings. Revision 1.1 2006/02/16 13:01:08 hiratsu Initial check in. *---------------------------------------------------------------------------*/ #include #include #include #include #include #include "util.h" #define PERM (NAND_PERM_OWNER_READ | NAND_PERM_OWNER_WRITE) // Owner can read/write #define ATTR 0x00 // No attributes. static void printDir (const char *path); static void createDir (const char *path); static void deleteDir (const char *path); static void changeDir (const char *path); static void printCurrentDir(void); static void createFile(const char *path, u8 perm); static void printDir(const char *path) { u32 num = 0; u32 idx = 0; u32 i = 0; char *buf = 0; NANDReadDir(path, NULL, &num); // Get number of elements. buf = (char*)alloc32((num*(NAND_MAX_NAME+1)+31)/32*32); if(!buf) { OSReport("Failed to alloc memory. Cannot print directory.\n"); return; } NANDReadDir(path, buf, &num); // Get directory list. for(i=0; i