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 (__wiiu__)
51 # include <iosuhax_disc_interface.h>
52 #elif defined(__gamecube__) || defined (__wii__)
53 # include <ogc/disc_io.h>
54 #else
55 # ifdef NDS
56 # include <nds/disc_io.h>
57 # else
58 # include <disc_io.h>
59 # endif
60 #endif
61 
62 /*
63 Initialise any inserted block-devices.
64 Add the fat device driver to the devoptab, making it available for standard file functions.
65 cacheSize: The number of pages to allocate for each inserted block-device
66 setAsDefaultDevice: if true, make this the default device driver for file operations
67 */
68 extern bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice);
69 
70 /*
71 Calls fatInit with setAsDefaultDevice = true and cacheSize optimised for the host system.
72 */
73 extern bool fatInitDefault (void);
74 
75 /*
76 Mount the device pointed to by interface, and set up a devoptab entry for it as "name:".
77 You can then access the filesystem using "name:/".
78 This will mount the active partition or the first valid partition on the disc,
79 and will use a cache size optimized for the host system.
80 */
81 extern bool fatMountSimple (const char* name, const DISC_INTERFACE* interface);
82 
83 /*
84 Mount the device pointed to by interface, and set up a devoptab entry for it as "name:".
85 You can then access the filesystem using "name:/".
86 If startSector = 0, it will mount the active partition of the first valid partition on
87 the disc. Otherwise it will try to mount the partition starting at startSector.
88 cacheSize specifies the number of pages to allocate for the cache.
89 This will not startup the disc, so you need to call interface->startup(); first.
90 */
91 extern bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage);
92 
93 /*
94 Unmount the partition specified by name.
95 If there are open files, it will attempt to synchronise them to disc.
96 */
97 extern void fatUnmount (const char* name);
98 
99 /*
100 Get Volume Label
101 */
102 extern void fatGetVolumeLabel (const char* name, char *label);
103 
104 /* File attributes */
105 #define ATTR_ARCHIVE 0x20 /* Archive */
106 #define ATTR_DIRECTORY 0x10 /* Directory */
107 #define ATTR_VOLUME 0x08 /* Volume */
108 #define ATTR_SYSTEM 0x04 /* System */
109 #define ATTR_HIDDEN 0x02 /* Hidden */
110 #define ATTR_READONLY 0x01 /* Read only */
111 
112 /*
113 Methods to modify DOS File Attributes
114 */
115 int FAT_getAttr(const char *file);
116 int FAT_setAttr(const char *file, uint8_t attr );
117 
118 #define LIBFAT_FEOS_MULTICWD
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #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