RetroArch
fat.h
Go to the documentation of this file.
1 /*
2  fat.h
3  Simple functionality for startup, mounting and unmounting of FAT-based devices.
4 
5  Copyright (c) 2006 - 2012
6  Michael "Chishm" Chisholm
7  Dave "WinterMute" Murphy
8 
9  Redistribution and use in source and binary forms, with or without modification,
10  are permitted provided that the following conditions are met:
11 
12  1. Redistributions of source code must retain the above copyright notice,
13  this list of conditions and the following disclaimer.
14  2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation and/or
16  other materials provided with the distribution.
17  3. The name of the author may not be used to endorse or promote products derived
18  from this software without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
21  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
23  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 
32 #ifndef _LIBFAT_H
33 #define _LIBFAT_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include "libfatversion.h"
40 
41 // When compiling for NDS, make sure NDS is defined
42 #ifndef NDS
43  #if defined ARM9 || defined ARM7
44  #define NDS
45  #endif
46 #endif
47 
48 #include <stdint.h>
49 
50 #if defined(__gamecube__) || defined (__wii__)
51 # include <ogc/disc_io.h>
52 #else
53 # ifdef NDS
54 # include <nds/disc_io.h>
55 # else
56 # include <disc_io.h>
57 # endif
58 #endif
59 
60 /*
61 Initialise any inserted block-devices.
62 Add the fat device driver to the devoptab, making it available for standard file functions.
63 cacheSize: The number of pages to allocate for each inserted block-device
64 setAsDefaultDevice: if true, make this the default device driver for file operations
65 */
66 extern bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice);
67 
68 /*
69 Calls fatInit with setAsDefaultDevice = true and cacheSize optimised for the host system.
70 */
71 extern bool fatInitDefault (void);
72 
73 /*
74 Mount the device pointed to by interface, and set up a devoptab entry for it as "name:".
75 You can then access the filesystem using "name:/".
76 This will mount the active partition or the first valid partition on the disc,
77 and will use a cache size optimized for the host system.
78 */
79 extern bool fatMountSimple (const char* name, const DISC_INTERFACE* interface);
80 
81 /*
82 Mount the device pointed to by interface, and set up a devoptab entry for it as "name:".
83 You can then access the filesystem using "name:/".
84 If startSector = 0, it will mount the active partition of the first valid partition on
85 the disc. Otherwise it will try to mount the partition starting at startSector.
86 cacheSize specifies the number of pages to allocate for the cache.
87 This will not startup the disc, so you need to call interface->startup(); first.
88 */
89 extern bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage);
90 
91 /*
92 Unmount the partition specified by name.
93 If there are open files, it will attempt to synchronise them to disc.
94 */
95 extern void fatUnmount (const char* name);
96 
97 /*
98 Get Volume Label
99 */
100 extern void fatGetVolumeLabel (const char* name, char *label);
101 
102 // File attributes
103 #define ATTR_ARCHIVE 0x20 // Archive
104 #define ATTR_DIRECTORY 0x10 // Directory
105 #define ATTR_VOLUME 0x08 // Volume
106 #define ATTR_SYSTEM 0x04 // System
107 #define ATTR_HIDDEN 0x02 // Hidden
108 #define ATTR_READONLY 0x01 // Read only
109 
110 /*
111 Methods to modify DOS File Attributes
112 */
113 int FAT_getAttr(const char *file);
114 int FAT_setAttr(const char *file, uint8_t attr );
115 
116 #define LIBFAT_FEOS_MULTICWD
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif // _LIBFAT_H
GLuint const GLchar * name
Definition: glext.h:6671
void fatUnmount(const char *name)
Definition: libfat.c:122
bool fatMountSimple(const char *name, const DISC_INTERFACE *interface)
Definition: libfat.c:117
bool fatInitDefault(void)
Definition: libfat.c:209
GLuint GLsizei const GLchar * label
Definition: glext.h:8583
uint32_t sec_t
Definition: iosuhax_disc_interface.h:40
int FAT_getAttr(const char *file)
Definition: fatfile.c:66
int FAT_setAttr(const char *file, uint8_t attr)
Definition: fatfile.c:73
void fatGetVolumeLabel(const char *name, char *label)
Definition: libfat.c:214
Definition: iosuhax_disc_interface.h:52
bool fatInit(uint32_t cacheSize, bool setAsDefaultDevice)
Definition: libfat.c:146
bool fatMount(const char *name, const DISC_INTERFACE *interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage)
Definition: libfat.c:71
Definition: civetweb.c:1024
unsigned char uint8_t
Definition: stdint.h:124
unsigned int uint32_t
Definition: stdint.h:126