Passer au contenu principal
Menu
← BACK TO WORK

Système de Fichiers C

CLI Tool Development

Développement d'un outil CLI performant en C pour la manipulation de fichiers binaires.

ClientProjet Lab
RoleDéveloppeur Système
Year2024
StackC, Linux, Make, Bash
Système de Fichiers C

THE CHALLENGE

Gérer efficacement la mémoire et assurer la portabilité du code sur différents systèmes Unix.

fileops.c
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <fcntl.h>
4
#include <unistd.h>
5
 
6
int read_binary_file(const char *filename) {
7
    int fd = open(filename, O_RDONLY);
8
    if (fd == -1) {
9
        perror("Error opening file");
10
        return -1;
11
    }
12
 
13
    char buffer[1024];
14
    ssize_t bytes_read;
15
 
16
    while ((bytes_read = read(fd, buffer, sizeof(buffer))) > 0) {
17
        write(STDOUT_FILENO, buffer, bytes_read);
18
    }
19
 
20
    close(fd);
21
    return 0;
22
}
Detail View

Explore More

All Projects