mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-05-18 15:29:16 +02:00
fygue: support close() primitive for file
This commit is contained in:
parent
b1b4e8a287
commit
20cb87c0c1
7 changed files with 51 additions and 1 deletions
|
@ -270,12 +270,14 @@ set(SOURCES
|
||||||
src/fs/fygue/fygue_dir_close.c
|
src/fs/fygue/fygue_dir_close.c
|
||||||
src/fs/fygue/fygue_file_lseek.c
|
src/fs/fygue/fygue_file_lseek.c
|
||||||
src/fs/fygue/fygue_file_write.c
|
src/fs/fygue/fygue_file_write.c
|
||||||
|
src/fs/fygue/fygue_file_close.c
|
||||||
src/fs/fygue/fat/cluster.c
|
src/fs/fygue/fat/cluster.c
|
||||||
src/fs/fygue/fat/initialize.c
|
src/fs/fygue/fat/initialize.c
|
||||||
src/fs/fygue/fat/fat_dir_read.c
|
src/fs/fygue/fat/fat_dir_read.c
|
||||||
src/fs/fygue/fat/fat_dir_close.c
|
src/fs/fygue/fat/fat_dir_close.c
|
||||||
src/fs/fygue/fat/fat_dir_stat.c
|
src/fs/fygue/fat/fat_dir_stat.c
|
||||||
src/fs/fygue/fat/fat_file_stat.c
|
src/fs/fygue/fat/fat_file_stat.c
|
||||||
|
src/fs/fygue/fat/fat_file_close.c
|
||||||
src/fs/fygue/fat/resolve.c
|
src/fs/fygue/fat/resolve.c
|
||||||
src/fs/fygue/fat/sector.c
|
src/fs/fygue/fat/sector.c
|
||||||
src/fs/fygue/flash/cluster.c
|
src/fs/fygue/flash/cluster.c
|
||||||
|
|
|
@ -152,6 +152,12 @@ extern int fygue_fat_file_stat(
|
||||||
struct stat *statbuf
|
struct stat *statbuf
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* fygue_fat_file_close(): closedir primitive */
|
||||||
|
extern int fygue_fat_file_close(
|
||||||
|
struct fygue_fat *fat,
|
||||||
|
struct fygue_fat_file *dir
|
||||||
|
);
|
||||||
|
|
||||||
//---
|
//---
|
||||||
// Cluster interface
|
// Cluster interface
|
||||||
//---
|
//---
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <string.h>
|
||||||
#include "fat.h"
|
#include "fat.h"
|
||||||
|
|
||||||
/* fygue_fat_dir_close(): closedir primitive */
|
/* fygue_fat_dir_close(): closedir primitive */
|
||||||
|
@ -6,6 +7,7 @@ int fygue_fat_dir_close(struct fygue_fat *fat, struct fygue_fat_dir *dir)
|
||||||
if (fat == NULL || dir == NULL)
|
if (fat == NULL || dir == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
// nothing to do here...
|
// nothing to do here...
|
||||||
|
memset(dir, 0x00, sizeof(struct fygue_fat_file));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/fs/fygue/fat/fat_file_close.c
Normal file
14
src/fs/fygue/fat/fat_file_close.c
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "fat.h"
|
||||||
|
|
||||||
|
/* fygue_fat_file_close(): close primitive */
|
||||||
|
int fygue_fat_file_close(struct fygue_fat *fat, struct fygue_fat_file *file)
|
||||||
|
{
|
||||||
|
if (fat == NULL || file == NULL)
|
||||||
|
return -1;
|
||||||
|
if (file->chunk != NULL)
|
||||||
|
free(file->chunk);
|
||||||
|
memset(file, 0x00, sizeof(struct fygue_fat_file));
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -87,7 +87,7 @@ const fs_descriptor_type_t fygue_descriptor_type = {
|
||||||
.read = NULL,
|
.read = NULL,
|
||||||
.write = (void*)&fygue_file_write,
|
.write = (void*)&fygue_file_write,
|
||||||
.lseek = (void*)&fygue_file_lseek,
|
.lseek = (void*)&fygue_file_lseek,
|
||||||
.close = NULL,
|
.close = (void*)&fygue_file_close,
|
||||||
};
|
};
|
||||||
|
|
||||||
const fs_descriptor_type_t fygue_dir_descriptor_type = {
|
const fs_descriptor_type_t fygue_dir_descriptor_type = {
|
||||||
|
|
|
@ -141,6 +141,9 @@ extern ssize_t fygue_file_write(
|
||||||
size_t size
|
size_t size
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* fygue_file_close(): close directory */
|
||||||
|
extern int fygue_file_close(struct fygue_descriptor *desc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
23
src/fs/fygue/fygue_file_close.c
Normal file
23
src/fs/fygue/fygue_file_close.c
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "fygue.h"
|
||||||
|
#include "fat/fat.h"
|
||||||
|
|
||||||
|
/* fygue_file_close(): close directory */
|
||||||
|
int fygue_file_close(struct fygue_descriptor *desc)
|
||||||
|
{
|
||||||
|
struct fygue_fsinfo *fsinfo;
|
||||||
|
|
||||||
|
ENOTSUP_IF_NOT_FYGUE(-1);
|
||||||
|
if (desc == NULL || desc->resolve.type != FYGUE_FILE_TYPE_FILE) {
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (fygue_mount(&fsinfo, true) != 0) {
|
||||||
|
errno = EIO;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fygue_fat_file_close(&(fsinfo->fat), &desc->resolve.file.fat);
|
||||||
|
memset(desc, 0x00, sizeof(struct fygue_descriptor));
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue