1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 #define SECTOR_SIZE 512
29 unsigned char name
[256]; /* Name plus \0 */
30 unsigned short attr
; /* Attributes */
31 unsigned char crttimetenth
; /* Millisecond creation
33 unsigned short crttime
; /* Creation time */
34 unsigned short crtdate
; /* Creation date */
35 unsigned short lstaccdate
; /* Last access date */
36 unsigned short wrttime
; /* Last write time */
37 unsigned short wrtdate
; /* Last write date */
38 unsigned int filesize
; /* File size in bytes */
39 int firstcluster
; /* fstclusterhi<<16 + fstcluslo */
42 #define FAT_ATTR_READ_ONLY 0x01
43 #define FAT_ATTR_HIDDEN 0x02
44 #define FAT_ATTR_SYSTEM 0x04
45 #define FAT_ATTR_VOLUME_ID 0x08
46 #define FAT_ATTR_DIRECTORY 0x10
47 #define FAT_ATTR_ARCHIVE 0x20
51 int firstcluster
; /* first cluster in file */
52 int lastcluster
; /* cluster of last access */
53 int lastsector
; /* sector of last access */
54 int clusternum
; /* current clusternum */
55 int sectornum
; /* sector number in this cluster */
56 unsigned int direntry
; /* short dir entry index from start of dir */
57 unsigned int direntries
; /* number of dir entries used by this file */
58 unsigned int dircluster
; /* first cluster of dir */
65 unsigned int entrycount
;
68 unsigned char sectorcache
[3][SECTOR_SIZE
];
72 extern int fat_mount(int startsector
);
73 extern void fat_size(unsigned int* size
, unsigned int* free
);
74 extern void fat_recalc_free(void);
75 extern int fat_create_dir(const char* name
,
76 struct fat_dir
* newdir
,
78 extern int fat_startsector(void);
79 extern int fat_open(unsigned int cluster
,
81 const struct fat_dir
* dir
);
82 extern int fat_create_file(const char* name
,
85 extern int fat_readwrite(struct fat_file
*ent
, int sectorcount
,
86 void* buf
, bool write
);
87 extern int fat_closewrite(struct fat_file
*ent
, int size
, int attr
);
88 extern int fat_seek(struct fat_file
*ent
, unsigned int sector
);
89 extern int fat_remove(struct fat_file
*ent
);
90 extern int fat_truncate(const struct fat_file
*ent
);
91 extern int fat_rename(struct fat_file
* file
,
93 const unsigned char* newname
,
96 extern int fat_opendir(struct fat_dir
*ent
, unsigned int currdir
,
97 const struct fat_dir
*parent_dir
);
98 extern int fat_getnext(struct fat_dir
*ent
, struct fat_direntry
*entry
);
99 extern int fat_get_cluster_size(void);