Finished the norm in stdme normal code
This commit is contained in:
parent
3cfbf07882
commit
5bc68504f9
19 changed files with 44 additions and 325 deletions
|
|
@ -6,33 +6,35 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/24 19:06:05 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/10 17:46:34 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/30 16:26:28 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/fs/close.h"
|
||||
#include "me/fs/open.h"
|
||||
#include "me/fs/read_to_vec.h"
|
||||
#include "me/fs/write.h"
|
||||
#include "me/fs/fs.h"
|
||||
#include "me/img/qoi.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/vec/vec_u8.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/// This has to be added into the me/fs/fs.h header at one point
|
||||
t_error read_to_vec(t_const_str filename, t_vec_u8 *out);
|
||||
|
||||
t_i32 qoi_write(t_const_str filename, const void *data,
|
||||
const t_qoi_desc *desc)
|
||||
{
|
||||
int f;
|
||||
t_fd *f;
|
||||
void *encoded;
|
||||
t_i32 size;
|
||||
|
||||
if (me_open(filename, false, true, &f))
|
||||
f = open_fd((t_str)filename, FD_WRITE, 0, FP_ALL_EXEC);
|
||||
if (f == NULL)
|
||||
return (0);
|
||||
encoded = qoi_encode(data, desc, &size);
|
||||
if (!encoded)
|
||||
return (me_close(f, NULL), 0);
|
||||
if (me_write(f, encoded, size))
|
||||
return (me_close(f, NULL), 0);
|
||||
me_close(f, NULL);
|
||||
return (close_fd(f), 0);
|
||||
if (write_fd(f, encoded, size, NULL))
|
||||
return (close_fd(f), 0);
|
||||
close_fd(f);
|
||||
mem_free(encoded);
|
||||
return (size);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue