summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-01-27 09:32:17 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-01-27 09:32:17 +0000
commit184fd554115beb52bb4037ddcd36d8db26d5938d (patch)
treeb653181904020b1875c67d07359770de9590d53d /firmware/drivers
parentb6a4f2fb2c9cf53cd4e59fd901974a81100f6711 (diff)
downloadrockbox-184fd554115beb52bb4037ddcd36d8db26d5938d.zip
rockbox-184fd554115beb52bb4037ddcd36d8db26d5938d.tar.gz
rockbox-184fd554115beb52bb4037ddcd36d8db26d5938d.tar.bz2
rockbox-184fd554115beb52bb4037ddcd36d8db26d5938d.tar.xz
Directories can now be renamed too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3167 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/fat.c13
-rw-r--r--firmware/drivers/fat.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 020a48b..9274a9c 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -1122,7 +1122,7 @@ static int create_dos_name(unsigned char *name, unsigned char *newname)
return 0;
}
-static int update_file_size( struct fat_file* file, int size )
+static int update_short_entry( struct fat_file* file, int size, int attr )
{
unsigned char buf[SECTOR_SIZE];
int sector = file->direntry / DIR_ENTRIES_PER_SECTOR;
@@ -1152,6 +1152,8 @@ static int update_file_size( struct fat_file* file, int size )
if (!entry[0] || entry[0] == 0xe5)
panicf("Updating size on empty dir entry %d\n", file->direntry);
+ entry[FATDIR_ATTR] = attr & 0xFF;
+
clusptr = (short*)(entry + FATDIR_FSTCLUSHI);
*clusptr = SWAB16(file->firstcluster >> 16);
@@ -1264,7 +1266,7 @@ int fat_truncate(struct fat_file *file)
return 0;
}
-int fat_closewrite(struct fat_file *file, int size)
+int fat_closewrite(struct fat_file *file, int size, int attr)
{
LDEBUGF("fat_closewrite(size=%d)\n",size);
@@ -1277,7 +1279,7 @@ int fat_closewrite(struct fat_file *file, int size)
}
if (file->dircluster)
- if (update_file_size(file, size) < 0)
+ if (update_short_entry(file, size, attr) < 0)
return -1;
flush_fat();
@@ -1392,7 +1394,8 @@ int fat_remove(struct fat_file* file)
int fat_rename(struct fat_file* file,
unsigned char* newname,
- int size)
+ int size,
+ int attr)
{
int err;
struct fat_dir dir;
@@ -1414,7 +1417,7 @@ int fat_rename(struct fat_file* file,
return -3;
/* write size and cluster link */
- err = update_file_size(&newfile, size);
+ err = update_short_entry(&newfile, size, attr);
if (err<0)
return -4;
diff --git a/firmware/drivers/fat.h b/firmware/drivers/fat.h
index 8d2382f..6a3e5cf 100644
--- a/firmware/drivers/fat.h
+++ b/firmware/drivers/fat.h
@@ -81,13 +81,13 @@ extern int fat_create_file(char* name,
struct fat_dir* dir);
extern int fat_readwrite(struct fat_file *ent, int sectorcount,
void* buf, bool write );
-extern int fat_closewrite(struct fat_file *ent, int size);
+extern int fat_closewrite(struct fat_file *ent, int size, int attr);
extern int fat_seek(struct fat_file *ent, unsigned int sector );
extern int fat_remove(struct fat_file *ent);
extern int fat_truncate(struct fat_file *ent);
extern int fat_rename(struct fat_file* file,
unsigned char* newname,
- int size);
+ int size, int attr);
extern int fat_opendir(struct fat_dir *ent, unsigned int currdir);
extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry);